Flutter:如果 Cloud_firestore 或其依赖项与 AndroidX 不兼容,它会破坏您的 Android 构建

2024-03-14

我不能同时使用这两个 flutter 插件:

  cloud_firestore: ^0.9.0+2
  barcode_scan: ^0.0.8

运行时,出现错误:

D8: Program type already present: android.arch.core.util.Function
     *********************************************************
WARNING: This version of cloud_firestore will break your Android build if it or its dependencies aren't compatible with AndroidX.
         See https: //goo.gl /CP92wY for more information on the problem and how to fix it.
         This warning prints for all Android build failures. The real root cause of the error may be unrelated.
         *********************************************************

FAILURE: Build failed with an exception.

当我删除其中之一时,它可以在 Android 手机上编译并运行。但两者不能走在一起。怎么修?


In short

将 multidex 库添加到 android 应用程序依赖项 (/android/app/build.gradle)

...
android {
  ...
  defaultConfig {
    ...
    multiDexEnabled true
  }
  ...
}
...
dependencies {
  implementation 'com.android.support:multidex:1.0.3' // use latest version
  ...
}
...

在android目录下 Gradel.properties 文件

Add

android.useAndroidX=true
android.enableJetifier=true
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Flutter:如果 Cloud_firestore 或其依赖项与 AndroidX 不兼容,它会破坏您的 Android 构建 的相关文章

随机推荐