【问题标题】:Flutter build failed with D8: Program type already presentFlutter build failed with D8:程序类型已存在
【发布时间】:2019-08-30 23:24:51
【问题描述】:

我正在开发一个颤振应用。

我找到了一个示例 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

BUILD FAILED in 0s
*******************************************************************************************
The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
See https://flutter.dev/docs/development/packages-and-plugins/androidx-compatibility for more information on the problem and how to fix it.
*******************************************************************************************
Finished with error: Gradle task assembleDebug failed with exit code 1

这个项目并不特别。 android部分,没有其他修改。 与“新的flutter项目”完全一样。

我尝试了一些东西:

  1. 迁移到 AndroidX

此操作失败并弹出错误消息。我尝试使用“重构 > 迁移到 android x”进行迁移,但它显示错误弹出窗口。 对我说的错误弹出窗口至少使用 compilesdkversion 28。 但是我已经用了28..怎么办?......

  1. 将 gradle 版本从 3.2.1 更改为 3.3.2。

但是构建失败,日志不同

Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
D8: Program type already present: android.support.v4.app.INotificationSideChannel

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: 
  Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
  Program type already present: android.support.v4.app.INotificationSideChannel

我不知道该怎么办...

这让我很累... 我只是想编码......

【问题讨论】:

标签: android gradle dart flutter


【解决方案1】:

我通过这个链接解决了这个问题:https://flutter.dev/docs/development/packages-and-plugins/androidx-compatibility

有 2 个迁移指南。

  1. 推荐

  2. 不推荐

就我而言,“推荐”解决方案不起作用...

但是,“不推荐”的解决方案有效...

...

这并不容易......

【讨论】:

    【解决方案2】:

    我试过这两行代码 flutter clean 然后 flutter run

    【讨论】:

      猜你喜欢
      • 2019-11-15
      • 1970-01-01
      • 2019-07-13
      • 2023-01-21
      • 2018-10-31
      • 1970-01-01
      • 2021-02-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多