gpt4 book ai didi

java - 从命令行编译时出现 com.android.dex.DexIndexOverflowException

转载 作者:行者123 更新时间:2023-12-01 09:37:04 25 4
gpt4 key购买 nike

我有一个小型 Android 应用程序无法从命令行编译。我可以毫无问题地构建应用程序并将其部署到 Android Studio 中的模拟器,但是当我尝试从命令行构建时,出现以下错误。

gradle clean assembleDebug

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:transformClassesWithDexForRelease'.

    com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536

  • 尝试:使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。

构建失败

我理解它是说我已经超出了此处描述的 Android 64k 方法限制:

https://developer.android.com/studio/build/multidex.html

但是为什么应用程序在 Android Studio 中编译得很好?知道从命令行编译时我做错了什么吗?提前致谢。

最佳答案

事实证明,我将所有 Google Play Service 库包含在我的依赖项中,即 build.gradle 中:

compile 'com.google.android.gms:play-services:9.4.0'

我删除了该依赖项并单独添加了每个 Play 服务库,即:

 compile 'com.google.android.gms:play-services-maps:9.4.0'

根据他们的文档:

https://developers.google.com/android/guides/setup

这样我就只包含我使用的库。现在,该应用程序可以在 Android Studio 和命令行中进行编译。我假设 Android Studio 将整个 Play Services 库替换为应用程序在编译时所需的内容,这就是为什么我之前可以在 Android Studio 中进行编译,但不能在命令行上进行编译,但是我无法证实这一点。希望这对其他人有帮助。

关于java - 从命令行编译时出现 com.android.dex.DexIndexOverflowException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38809850/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com