如何解决Flutter的重复类问题?

jjjwad0x  于 2023-05-19  发布在  Flutter
关注(0)|答案(2)|浏览(263)

加入后
位置:^1.4.1
到我在pubspec.yaml中的依赖项:

dependencies:
  flutter:
    sdk: flutter

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^0.1.2
  rxdart: ^0.20.0
  http: ^0.12.0
  date_format: ^1.0.5
  intl: ^0.15.7
  fluttertoast: ^2.2.3
  location: ^1.4.1

我做Packages get,一切都很好,但是当我尝试构建它时,应用程序崩溃并显示一条消息:
正在调试模式下启动Lenovo K33 a48上的lib\main.dart...正在初始化gradle...正在解析依赖项... Gradle任务“assembleDebug”... D8:程序类型已存在:android.support.v4.app.INotificationSideChannel
失败:生成失败,出现异常。

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

com.android.builder.dexing. DexArchiveMergeException:合并dex存档时出错:“Here goes the list of all jar archives”在www.example.com了解如何解决问题https://developer.android.com/studio/build/dependencies#duplicate_classes。程序类型已经存在:android.support.v4.app.INotificationSideChannel

  • Try:使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获取更多日志输出。使用--scan运行以获得完整的见解。
  • https://help.gradle.org获取更多帮助

BUILD FAILED in 18s Finished with error:Gradle任务assembleDebug失败,退出代码为% 1
我的目标是28。我使用Android Studio 3.2.1帮助将非常感谢!

31moq8wy

31moq8wy1#

这是因为您正在使用的库使用相同的依赖关系。

解决方案1

1.在VSCode搜索(Ctrl+Shift + P)
1.在您errorandroid.support.v4.app.INotificationSideChannel.搜索关键字 Notification/Side/Channel 中。选一个。
1.如果存在相同的依赖关系,则意味着存在重复的库。
1.解决方法:删除正在使用的库

方案2(推荐)

1.在VSCode搜索(Ctrl+Shift + P)
1.在您errorandroid.support.v4.app.INotificationSideChannel.搜索关键字 Notification/Side/Channel 中。选一个。
1.找到使用相同依赖关系的库,然后更新到latest package version
1.此解决方案将保留您正在使用的库,而不会将其删除

llmtgqce

llmtgqce2#

我无法复制你报告的行为。正如你在评论中提到的,这个问题似乎已经通过插件更新解决了。运行flutter clean应该可以解决依赖项缓存中引起的大多数冲突。

相关问题