Can not build the project after upgrading to android - P

只谈情不闲聊 提交于 2019-11-27 03:23:51

问题


Below are the errors which I am getting

C:\Users\Dell\.gradle\caches\transforms-1\files-1.1\appcompat-v7-28.0.0-alpha1.aar\51cd62c84e9404bd66ab4daf252c48a1\res\values-v28\values-v28.xml
Error:(9, 5) error: resource android:attr/dialogCornerRadius not found.
C:\Users\Dell\.gradle\caches\transforms-1\files-1.1\appcompat-v7-28.0.0-alpha1.aar\51cd62c84e9404bd66ab4daf252c48a1\res\values\values.xml
Error:(252, 5) error: resource android:attr/fontVariationSettings not found.
Error:(252, 5) error: resource android:attr/ttcIndex not found.
E:\20thJune2017_7PM\trunk\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values-v28\values-v28.xml
Error:(11) error: resource android:attr/dialogCornerRadius not found.
Error:(7) resource android:attr/dialogCornerRadius not found.
Error:(11) resource android:attr/dialogCornerRadius not found.
E:\20thJune2017_7PM\trunk\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml
Error:(486) resource android:attr/fontVariationSettings not found.
Error:(486) resource android:attr/ttcIndex not found.
Error:failed linking references.
Error:java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:Execution failed for task ':app:processDebugResources'.
> Failed to execute aapt

Below is my build.gradle(app level)

   dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:+'
    compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha3'
    compile 'com.android.support:design:+'
    compile 'com.android.support:support-v4:+'
    testCompile 'junit:junit:4.12'
    compile 'com.squareup.retrofit2:retrofit:2.1.0'
    compile 'com.squareup.retrofit2:converter-gson:2.1.0'
    compile 'com.google.code.gson:gson:2.7'
    compile 'de.hdodenhof:circleimageview:2.1.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.github.fiskurgit:ChipCloud:2.1.1'
    compile 'com.google.android.gms:play-services-maps:11.4.0'
    compile 'com.squareup.okhttp3:logging-interceptor:3.3.0'
    compile 'commons-codec:commons-codec:1.10'
    compile 'com.crittercism:crittercism-android-agent:+'
    compile 'ch.hsr:geohash:1.3.0'
    compile 'com.google.firebase:firebase-messaging:11.4.0'
    compile 'com.google.firebase:firebase-core:11.4.0'
    compile 'com.google.android.gms:play-services-analytics:11.4.0'
    compile 'com.ahmedjazzar.rosetta:rosetta:1.0.1'
}

I have tried different solutions from stackoverflow but none worked.Can you please help me on this.Thanks in advance.


回答1:


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




回答2:


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.




回答3:


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.




回答4:


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




回答5:


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.




回答6:


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...




回答7:


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'


来源:https://stackoverflow.com/questions/49249713/can-not-build-the-project-after-upgrading-to-android-p

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