Android SDK 26 build error

↘锁芯ラ 提交于 2019-12-11 07:07:39

问题


After I updated to SDK version 26 I tried to build an apk but got this error:

Error:Execution failed for task ':app:transformClassesWithFirebasePerformancePluginForFacebookDebug'.
> android/support/v7/app/ActionBarActivity

Stay with SDK version 25 is fine but got error message in build.gradle said:

all com.android.support libraries must use the exact same version

Dependency Report (where it failed):

Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
:app:transformClassesWithFirebasePerformancePluginForFacebookDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesWithFirebasePerformancePluginForFacebookDebug'.
> android/support/v7/app/ActionBarActivity

Update 1: I've found the root cause but still, need some suggestions. I looked into dependencies report. Support library 26.1.0 is from another library

+--- com.onesignal:OneSignal:3.6.2
|    +--- com.google.android.gms:play-services-gcm:[10.2.1,11.3.0) -> 11.2.2
|    |    +--- com.google.android.gms:play-services-base:11.2.2 (*)
|    |    +--- com.google.android.gms:play-services-basement:11.2.2 (*)
|    |    \--- com.google.android.gms:play-services-iid:11.2.2
|    |         +--- com.google.android.gms:play-services-base:11.2.2 (*)
|    |         \--- com.google.android.gms:play-services-basement:11.2.2 (*)
|    +--- com.google.android.gms:play-services-location:[10.2.1,11.3.0) -> 11.2.2
|    |    +--- com.google.android.gms:play-services-base:11.2.2 (*)
|    |    +--- com.google.android.gms:play-services-basement:11.2.2 (*)
|    |    \--- com.google.android.gms:play-services-tasks:11.2.2 (*)
|    +--- com.android.support:support-v4:[26.0.0,26.2.0) -> 26.1.0 (*)
|    \--- com.android.support:customtabs:[26.0.0,26.2.0) -> 26.1.0 (*)
\---

Update 2: I've set the facebook sdk usage as below:

compile('com.facebook.android:facebook-android-sdk:4.26.0') {
    exclude group: 'com.android.support', module: 'appcompat-v7'
}

but still getting the same error

So How can I resolve the conflict from this?


回答1:


You need to stick with support library 25.3.1, because facebook sdk version 4.26.0 still using it. You can take a look at its build.gradle, it still using 25.3.1:

// Facebook Dependencies
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:customtabs:25.3.1'

For the onesignal error, please read Troubleshooting Androidn about it, here the excerpt:

OneSignal automatically adds the following dependencies;

com.google.android.gms - Version 11.2.+
com.android.support - Version 26.1.+

If you get mixed version warnings like above in your build.gradle please make sure to update your other dependencies to match these versions.

If you must keep using an older version of these decencies add the following 4 lines, replacing the versions with the ones you require.

compile 'com.google.android.gms:play-services-gcm:11.2.+'
compile 'com.google.android.gms:play-services-location:11.2.+' 

compile 'com.android.support:support-v4:26.1.+'
compile 'com.android.support:customtabs:26.1.+'



回答2:


Eventually, I resolved it by assigning version compulsorily. Thanks to @Eugen Pechanec and @ישו אוהב אותך for inspiring me.

def gmsVersion = '11.2.2'
compile("com.google.android.gms:play-services-gcm:${gmsVersion}") {
    force = true
}
compile("com.google.android.gms:play-services-location:${gmsVersion}") {
    force = true
}

def androidSupportVersion = '25.3.1'
compile("com.android.support:support-v4:${androidSupportVersion}")  {
    force = true
}
compile("com.android.support:customtabs:${androidSupportVersion}")  {
    force = true
}


来源:https://stackoverflow.com/questions/46316151/android-sdk-26-build-error

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