问题:
使用了第三方库--barcode_scan ^1.0.0出现了编译和运行不一致问题
Android dependency 'androidx.XX:XX-runtime' has different version for the compile (1.0.0-rc01) and runtime (1.0.0) classpath.
(如:Android dependency 'androidx.core:core' has different version for the compile (1.0.0) and runtime (1.0.1) classpath. You should manually set the same version via DependencyResolution)
解决:
在app下的gradle文件下,复制以下代码到你的项目中的gradle,重新运行。如果运行通过恭喜你,不过很可能又出现新的编译问题,如果还是不通过,请继续查阅我下一篇文章。
buildscript {
ext.kotlin_version = '1.2.51' //第三方库采用kotlin
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
//依赖kotlin版本
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.2.0'
}
subprojects {
//根据提示使用对应的版本
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "27.1.1"
}
if (details.requested.group == 'androidx.core'
&& !details.requested.name.contains('androidx') ) {
details.useVersion "1.0.1"
}
}
}
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}