gpt4 book ai didi

Android Studio 多个dex文件定义 Lcom/abc/xyz/BuildConfig

转载 作者:搜寻专家 更新时间:2023-11-01 07:55:24 30 4
gpt4 key购买 nike

我是 Android Studio 的新手,每次尝试运行我的应用程序时,都会遇到异常

Error:Execution failed for task ':abc:dexDebug'.
com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/home/nik/Installs/adt-bundle-linux-x86_64-20140702/sdk/build-tools/21.1.2/dx --dex --no-optimize --output /home/nik/workspace/androidstudio/abc/build/intermediates/dex/debug --input-list=/home/nik/workspace/androidstudio/abc/build/intermediates/tmp/dex/debug/inputList.txt


Error Code:
2


Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/abc/xyz/BuildConfig;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)

尝试了很多解决方案,例如删除 BuildConfig 文件等,但都没有成功。经过大量谷歌搜索后,我才明白,与多个依赖文件相关但无法解决的问题。

也试试命令gradle -q 依赖项但失败并出现此错误

失败:构建因内部错误而中止。

  • 出了什么问题:由于意外的内部错误,构建中止。请在以下位置提交问题:http://forums.gradle.org .

我还想提一下,我正在尝试从 eclipse 迁移我的项目,并在 Android Studio 中运行 Build->Rebuild Project 时成功构建它

boxAndroidLibraryV2

dependencies {


compile project(':boxJavaLibraryV2')
compile 'com.android.support:support-v4:19.1.0'
//compile 'com.android.support:support-v4:18.0.0'
compile files('libs/commons-codec.jar')
compile files('libs/commons-io-2.3.jar')
compile files('libs/commons-lang-2.6.jar')
compile files('libs/commons-logging-1.1.1.jar')
compile files('libs/httpclient-cache-4.2.5.jar')
compile files('libs/httpmime-4.2.5.jar')
compile files('libs/jackson-annotations-2.0.0.jar')
compile files('libs/jackson-core-2-1.0.0.jar')
compile files('libs/jackson-databind-2-1.0.0.jar')
}

boxJavaLibraryV2

dependencies {


compile files('libs/cglib-nodep-2.2.2.jar')
compile files('libs/commons-codec-1.6.jar')
compile files('libs/commons-io-2.3.jar')
compile files('libs/commons-lang-2.6.jar')
compile files('libs/commons-logging-1.1.1.jar')
compile files('libs/easymock-3.1.jar')
compile files('libs/httpclient-4.2.5.jar')
compile files('libs/httpclient-cache-4.2.5.jar')
compile files('libs/httpcore-4.2.4.jar')
compile files('libs/httpmime-4.2.5.jar')
compile files('libs/jackson-annotations-2.0.0.jar')
compile files('libs/jackson-core-2-1.0.0.jar')
compile files('libs/jackson-databind-2-1.0.0.jar')
compile files('libs/junit-4.8.2.jar')
compile files('libs/powermock-easymock-1.4.12-full.jar')
compile files('libs/robolectric-1.2-20121030.213744-165-jar-with-dependencies.jar')
}

我的图书馆

dependencies {


compile 'com.android.support:support-v4:19.1.0'
compile 'com.google.guava:guava:17.0'
compile files('libs/commons-codec.jar')
compile files('libs/sqlcipher.jar')
}

我的应用

dependencies {


compile project(':boxAndroidLibraryV2')
compile project(':liveSdk')
compile project(':mylib')
compile 'com.android.support:support-v4:19.1.0'
compile 'com.google.http-client:google-http-client-gson:1.19.0'
compile 'com.google.code.gson:gson:2.1'
compile 'com.google.android.gms:play-services:+'
compile files('libs/HockeySDK-3.0.2.jar')
compile files('libs/dropbox-android-sdk-1.5.4.jar')
compile files('libs/google-api-client-1.14.1-beta.jar')
compile files('libs/google-api-client-android-1.14.1-beta.jar')
compile files('libs/google-api-services-drive-v2-rev70-1.14.1-beta.jar')
compile files('libs/google-http-client-1.14.1-beta.jar')
compile files('libs/google-http-client-android-1.14.1-beta.jar')
compile files('libs/google-oauth-client-1.14.1-beta.jar')
compile files('libs/icu4j-4.8.1.jar')
compile files('libs/in-app-purchasing-2.0.59.jar')
compile files('libs/json_simple-1.1.jar')

}

我知道一些依赖项在盒子库中是多重的,比如

编译文件('libs/commons-io-2.3.jar')编译文件('libs/commons-lang-2.6.jar')

但如果我尝试删除这些而不是面临异常

Error:(6, 29) error: package org.apache.commons.io does not exist
Error:(80, 13) error: cannot find symbol variable IOUtils
Error:(6, 32) error: cannot find symbol class CharEncoding
Error:(57, 75) error: cannot find symbol variable CharEncoding
Error:(58, 79) error: cannot find symbol variable CharEncoding etc...

谢谢你的建议

最佳答案

经过多次尝试

dexOptions {
preDexLibraries = false
javaMaxHeapSize "4g"
}

这对我有用..

关于Android Studio 多个dex文件定义 Lcom/abc/xyz/BuildConfig,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28428587/

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