Android support 26.0.0-alpha1 产生的问题(zz)

针对以下两个错误 

Java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/animation/AnimatorCompatHelper

 和 

Manifest merger failed : Attribute meta-data#Android.support.VERSION@value 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'
           }
       }
   }
}


上面这段作为顶级节点放在app/build.gradle文件的随便什么位置都可以


引用:

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





posted @ 2017-07-12 16:09  拿走不谢  阅读(2231)  评论(0编辑  收藏  举报