Gradle重復(fù)依賴在開(kāi)發(fā)中很常見(jiàn),昨天遇到一個(gè)問(wèn)題,今天才解決,問(wèn)題報(bào)的異常是java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/animation/AnimatorCompatHelper;網(wǎng)上查到的資料都是修改app的build.gradle文件,結(jié)果我修改的是被依賴的library模塊的build.gradle文件,因?yàn)槲宜械囊蕾嚩寂渲玫搅薼ibrary模塊,結(jié)果問(wèn)題依舊,今天靈機(jī)一動(dòng)是不是這種配置像kapt一樣需要在上層模塊配置才可以,然后我就把gradle配置該到了app里,結(jié)果解決了問(wèn)題,下面上代碼:
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里,問(wèn)題解決