【问题标题】:Android dependency 'androidx.core:core' has different version for the compile (1.0.0) and runtime (1.0.1) classpathAndroid 依赖 'androidx.core:core' 的编译(1.0.0)和运行时(1.0.1)类路径有不同的版本
【发布时间】:2019-08-19 12:43:37
【问题描述】:

我最近在我的 Flutter 应用中添加了一个新库。它开始向我显示一个错误:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:preDebugBuild'.
> 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

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUİLD FAILED in 14s

【问题讨论】:

    标签: flutter dart barcode-scanner flutter-dependencies


    【解决方案1】:

    尝试转到依赖项并将编译更改为 1.0.1

    【讨论】:

      【解决方案2】:

      Step 1. 进入android文件夹下的gradle.properties,添加如下代码:

      org.gradle.jvmargs=-Xmx1536M
      android.useAndroidX=true
      android.enableJetifier=true
      

      第 2 步。现在转到 android 下的 build.gradle,而不是 app->build.gradle 下。在查看文件时,请确保它以单词 builscript 开头(这样可以确保您位于正确的 build.gradle 文件中。)

      步骤 3. Ctrl+A 该文件中的所有内容,注意 ctrl+A 删除所有内容并粘贴这段代码所需的所有内容:

      buildscript {
          ext.kotlin_version = '1.3.0'
          repositories {
              google()
              jcenter()
          }
      
          dependencies {
              classpath 'com.android.tools.build:gradle:3.3.1'
              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
      }
      

      需要特别注意的一点是,在编译过程中,您很可能会看到这条警告消息全是红色的。在得出任何结论之前,请不要害怕,让整个编译完成。虽然它是红色的,但它不会停止您的编译,因为您会在底部看到一个显示编译进度的旋转圆圈。在那之后,它会消失,您将能够运行该应用程序。以下是警告信息:

      注意: C:\flutter.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.12.11\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java 使用或覆盖已弃用的 API。注意:重新编译 -Xlint:deprecation 了解详情。注意:C:\flutter.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.12.11\android\src\main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java 使用未经检查或不安全的操作。注意:重新编译 -Xlint:详细信息未选中。错误:[TAG] 无法解析变量 '${animal.sniffer.version}' 注意: C:\flutter.pub-cache\hosted\pub.dartlang.org\mlkit-0.15.0\android\src\main\java\com\azihsoyn\flutter\mlkit\MlkitPlugin.java 使用未经检查或不安全的操作。注意:重新编译 -Xlint:详细信息未选中。

      然后轰隆隆!而已。相信我,这绝对可以解决您的问题。

      如果您仍然遇到任何此类问题,请尝试实施此link 中提到的其他一些解决方案。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-08-28
        • 2020-03-17
        • 1970-01-01
        • 2023-03-14
        • 2018-04-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多