解决java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/animation/AnimatorCom...

Gradle重复依赖在开发中很常见,昨天遇到一个问题,今天才解决,问题报的异常是java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/animation/AnimatorCompatHelper;网上查到的资料都是修改app的build.gradle文件,结果我修改的是被依赖的library模块的build.gradle文件,因为我所有的依赖都配置到了library模块,结果问题依旧,今天灵机一动是不是这种配置像kapt一样需要在上层模块配置才可以,然后我就把gradle配置该到了app里,结果解决了问题,下面上代码:

    configurations.all {
        resolutionStrategy.eachDependency { DependencyResolveDetails details ->
            def requested = details.requested
            if (requested.group == 'com.android.support') {
                if (!requested.name.startsWith("multidex")) {
                    details.useVersion '27.1.1'
                }
            }
        }
    }

我把上面的代码配置到了app的build.gradle里,问题解决

你可能感兴趣的:(解决java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/animation/AnimatorCom...)