FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ‘:app:preDebugBuild’.
> Android dependency ‘androidx.drawerlayout:drawerlayout’ has different version for the compile (1.0.0-rc01) and runtime (1.0.0) classpath. You should manually set the same version via DependencyResolution
方法一:
在网上找到用如下的方法可以解决:
configurations.all {
resolutionStrategy {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == ‘androidx.core’) {
details.useVersion “1.0.1”
}
if (details.requested.group == ‘androidx.drawerlayout’) {
details.useVersion “1.0.0”
}
if (details.requested.group == ‘androidx.lifecycle’) {
details.useVersion “2.0.0”
}
if (details.requested.group == ‘androidx.versionedparcelable’) {
details.useVersion “1.0.0”
}
if (details.requested.group == ‘androidx.fragment’) {
details.useVersion “1.0.0”
}
if (details.requested.group == ‘androidx.appcompat’) {
details.useVersion “1.0.1”
}
}
}
}
但是,还是会有新的androidx.XXXX报出来,所以用了第二种方法。
方法二:android/app/build.gradle
(但是我在android/build.gradle``文件中找的)
,升级 gradle 依赖:
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
}
改成3.3.1
就解决了这个问题,原来是3.2.1
。