当前位置: 代码迷 >> 综合 >> flutter-使用第三方库,编译和运行版本不一致问题
  详细解决方案

flutter-使用第三方库,编译和运行版本不一致问题

热度:35   发布时间:2023-12-14 05:54:24.0

问题:

         使用了第三方库--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'  //第三方库采用kotlinrepositories {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
}