Android support 26.0.0-alpha1 產生的問題
針對以下兩個錯誤
java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/animation/AnimatorCompatHelper
和
Manifest merger failed : Attribute meta-data#[email protected] value=(25.3.0) from [com.android.support:support-v13:25.3.0] AndroidManifest.xml:27:9-31 is also present at [com.android.support:preference-v7:26.0.0-alpha1] AndroidManifest.xml:24:9-38
value=(26.0.0-alpha1). Suggestion: add 'tools:replace="android:value"' to element at AndroidManifest.xml:25:5-27:34 to override.
都是因為如果程式內出現不同的,support或者其他外部引用庫的多個版本,Gradle在進行合併的時候會使用本地持有的,最高版本的來進行編譯,所以25的support就有可能引用26的東西,就會出現 屬性 merge 錯誤 ,或者Class丟失,解決方法就是強制使用相同版本的庫:
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion '25.3.0'
}
}
}
}
引用:
http://stackoverflow.com/questions/42949974/android-support-repo-46-0-0-with-android-studio-2-3/42957234#42957234
http://stackoverflow.com/questions/42987363/java-lang-noclassdeffounderror-failed-resolution-of-landroid-support-v4-animat