Can not build the project after upgrading to android - P

荒凉一梦 提交于 2019-11-28 10:03:42

I already answered a similar question here.

Try changing the compileSdkVersion to:

compileSdkVersion 28

These attributes were added in this version. Check here, here and here

Delete these lines and sync:

compile 'com.android.support:appcompat-v7:+'
compile 'com.android.support:design:+'
compile 'com.android.support:support-v4:+'

then goto File -> Project Structure then goto Dependencies and click + button on top right

select library dependencies From the list. Select the above 3 dependencies and click OK

Make sure that compileSdkVerison and targetSdkVersion are same as that in these dependencies.

You need to use more specific versions of your dependencies

compile 'com.android.support:design:+'

selects the newest design support library (28.0.0-alpha) which is not compatible with your compile SDK <28. Change to

compile 'com.android.support:design:27.+'

or preferably a specific version such as

compile 'com.android.support:design:27.1.0'

Similarly for your other dynamic dependencies with + in their version.

If you are still facing this problem, try to debug in terminal.There are many reasons for occurrence of this error, but one cannot pin point exact reason unless you debug in detail. Run this command in terminal , you may get to know where exactly you are getting this bug:

./gradlew installDebug

I had a similar problem and the solution was to migrate to AndroidX.

With Android Studio 3.2 and higher, you can quickly migrate an existing project to use AndroidX by selecting Refactor > Migrate to AndroidX from the menu bar.

If you have any Maven dependencies that have not been migrated to the AndroidX namespace, the Android Studio build system also migrates those dependencies for you when you set the following two flags to true in your gradle.properties file:

android.useAndroidX=true
android.enableJetifier=true

To migrate an existing project that does not use any third-party libraries with dependencies that need converting, you can set the android.useAndroidX flag to true and the android.enableJetifier flag to false.

Source.

look @ your Compile SDK Version and (mine whas API: 26: Android 8.0)

and change in your Build.gradle Module:app the next thing:

->>>form: implementation 'com.android.support:design:28.0.0-beta1'

implementation 'com.android.support:cardview-v7:28.0.0-beta1'
implementation 'com.android.support:recyclerview-v7:28.0.0-beta1'
implementation 'com.android.support:appcompat-v7:28.0.0-beta1'

->>>to: implementation 'com.android.support:design:26.0.0-beta1'

implementation 'com.android.support:cardview-v7:26.0.0-beta1'
implementation 'com.android.support:recyclerview-v7:26.0.0-beta1'
implementation 'com.android.support:appcompat-v7:26.0.0-beta1'

have a nice day...

Ammar Ibrahim

Try this:

Go to dependencies at gradle (module) and replace all the dependencies with the following:

dependencies {
  debugImplementation 'com.android.support.constraint:constraint-layout:1.1.2'
  implementation fileTree(include: ['*.jar'], dir: 'libs')
  androidTestImplementation 'junit:junit:4.12'
  implementation 'com.android.support:appcompat-v7:26.1.0'
  implementation 'com.android.support:support-v4:26.1.0'
  implementation 'com.android.support:design:26.1.0'
}

Change all SdkVersion to 26

Then under compileSdkVersion add the following:

buildToolsVersion '27.0.3'
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!