当我包含谷歌地图时,我的构建失败

Posted

技术标签:

【中文标题】当我包含谷歌地图时,我的构建失败【英文标题】:When I include google maps my build fails 【发布时间】:2019-07-15 07:44:05 【问题描述】:

当我在 pubspec.yaml 中包含“谷歌地图”依赖项时

google_maps_flutter: ^0.2.0+3

我的构建失败了:

在为 x86 构建的 android SDK 上以调试模式启动 lib\main.dart... D8:程序类型已经存在:android.support.v4.media.MediaBrowserCompat$ConnectionCallback$ConnectionCallbackInternal ****************************************************** ******* 警告:如果此版本的 google_maps_flutter 或其依赖项与 AndroidX 不兼容,它将破坏您的 Android 构建。 有关该问题以及如何解决该问题的更多信息,请参阅 xxxxxxxxxxx。 此警告会针对所有 Android 构建失败打印。错误的真正根本原因可能是无关的。 ****************************************************** *******

FAILURE:构建失败并出现异常。

出了什么问题: 任务 ':app:transformDexArchiveWithExternalLibsDexMergerForDebug' 执行失败。

com.android.builder.dexing.DexArchiveMergerException: 合并 dex 档案时出错:C:\Users\philb\flutter_course2\build\app\intermediates\transforms\dexBuilder\debug\4.jar, C:\Users\philb \flutter_course2\build\app\intermediates\transforms\dexBuilder\debug\5.jar, C:\Users\philb\flutter_course2\build\app\intermediates\transforms\dexBuilder\debug\6.jar, C:\Users\philb \flutter_course2\build\app\intermediates\transforms\dexBuilder\debug\7.jar, C:\Users\philb\flutter_course2\build\app\intermediates\transforms\dexBuilder\debug\8.jar, C:\Users\philb \flutter_course2\build\app\intermediates\transforms\dexBuilder\debug\9.jar, C:\Users\philb\flutter_course2\build\app\intermediates\transforms\dexBuilder\debug\10.jar, C:\Users\philb \flutter_course2\build\app\intermediates\transforms\dexBuilder\debug\11.jar, C:\Users\philb\flutter_course2\build\app\intermediates\transforms\dexBuilder\debug\12.jar, C:\Users\philb \flutter_course2\build\app\intermediates\transforms\dexBuilder\debug\13.jar, C:\Us ers\philb\flutter_course2\build\app\intermediates\transforms\dexBuilder\debug\14.jar, C:\Users\philb\flutter_course2\build\app\intermediates\transforms\dexBuilder\debug\15.jar, C:\用户\philb\flutter_course2\build\app\intermediates\transforms\dexBuilder\debug\16.jar, C:\Users\philb\flutter_course2\build\app\intermediates\transforms\dexBuilder\debug\17.jar, C:\用户\philb\flutter_course2\build\app\intermediates\transforms\dexBuilder\debug\18.jar, C:\Users\philb\flutter_course2\build\app\intermediates\transforms\dexBuilder\debug\19.jar, C:\用户\philb\flutter_course2\build\app\intermediates\transforms\dexBuilder\debug\20.jar, C:\Users\philb\flutter_course2\build\app\intermediates\transforms\dexBuilder\debug\21.jar, C:\用户\philb\flutter_course2\build\app\intermediates\transforms\dexBuilder\debug\22.jar, C:\Users\philb\flutter_course2\build\app\intermediates\transforms\dexBuilder\debug\23.jar, C:\用户\philb\flutter_course2\build\app\intermediates\transforms\dexBuilder\debug\24.jar, C:\U sers\philb\flutter_course2\build\app\intermediates\transforms\dexBuilder\debug\25.jar, C:\Users\philb\flutter_course2\build\app\intermediates\transforms\dexBuilder\debug\26.jar, C:\用户\philb\flutter_course2\build\app\intermediates\transforms\dexBuilder\debug\27.jar, C:\Users\philb\flutter_course2\build\app\intermediates\transforms\dexBuilder\debug\28.jar, C:\用户\philb\flutter_course2\build\app\intermediates\transforms\dexBuilder\debug\29.jar, C:\Users\philb\flutter_course2\build\app\intermediates\transforms\dexBuilder\debug\30.jar, C:\用户\philb\flutter_course2\build\app\intermediates\transforms\dexBuilder\debug\31.jar, C:\Users\philb\flutter_course2\build\app\intermediates\transforms\dexBuilder\debug\32.jar, C:\用户\philb\flutter_course2\build\app\intermediates\transforms\dexBuilder\debug\33.jar, C:\Users\philb\flutter_course2\build\app\intermediates\transforms\dexBuilder\debug\34.jar, C:\用户\philb\flutter_course2\build\app\intermediates\transforms\dexBuilder\debug\35.jar, C:\用户\philb\flutter_course2\build\app\intermediates\transforms\dexBuilder\debug\36.jar, C:\Users\philb\flutter_course2\build\app\intermediates\transforms\dexBuilder\debug\50.jar, C:\用户\philb\flutter_course2\build\app\intermediates\transforms\dexBuilder\debug\55.jar, C:\Users\philb\flutter_course2\build\app\intermediates\transforms\dexBuilder\debug\60.jar, C:\用户\philb\flutter_course2\build\app\intermediates\transforms\dexBuilder\debug\65.jar, C:\Users\philb\flutter_course2\build\app\intermediates\transforms\dexBuilder\debug\70.jar, C:\用户\philb\flutter_course2\build\app\intermediates\transforms\dexBuilder\debug\75.jar, C:\Users\philb\flutter_course2\build\app\intermediates\transforms\dexBuilder\debug\80.jar, C:\用户\philb\flutter_course2\build\app\intermediates\transforms\dexBuilder\debug\85.jar, C:\Users\philb\flutter_course2\build\app\intermediates\transforms\dexBuilder\debug\90.jar, C:\用户\philb\flutter_course2\build\app\intermediates\transforms\dexBuilder\debug\95.jar,C: \Users\philb\flutter_course2\build\app\intermediates\transforms\dexBuilder\debug\100.jar, C:\Users\philb\flutter_course2\build\app\intermediates\transforms\dexBuilder\debug\105.jar, C: \Users\philb\flutter_course2\build\app\intermediates\transforms\dexBuilder\debug\110.jar, C:\Users\philb\flutter_course2\build\app\intermediates\transforms\dexBuilder\debug\115.jar

有人可以指出我正确的方向来理解和追踪这一点。这个项目以前构建得很好。

【问题讨论】:

你跑过flutter包吗 是的,我有 - 每次我在谷歌地图中添加评论或添加其他依赖项时都会运行它 【参考方案1】:

这是因为您的应用中有 google_maps_plugin 版本正在使用 androidx,并且您的应用和/或其他一些依赖项可能正在使用 android 支持库。我提供了一些方法来解决这种问题here 和here。 但是您需要做的是migrate all your app to androidx 并使用已经迁移的更新依赖版本。

另一种方法是avoid androidx 将您的依赖包降级为 androidx 之前的版本。

有关 Flutter 应用程序 androidx 迁移的更多详细信息,请参阅原始文档 reference

希望对你有帮助。

【讨论】:

以上是关于当我包含谷歌地图时,我的构建失败的主要内容,如果未能解决你的问题,请参考以下文章

谷歌地图 api 构建失败

颤动我的谷歌地图在发布版本上不起作用或显示

Flutter:当我的应用不在前台时如何显示横幅(如地图/谷歌地图)?

谷歌地图 Default.css 样式表导入

片段更改时如何隐藏地图视图(谷歌地图v2)

当我在我的应用程序中按下按钮时,我如何能够打开谷歌地图?