- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我是 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 依赖项但失败并出现此错误
失败:构建因内部错误而中止。
我还想提一下,我正在尝试从 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/
每当我运行 Android 应用程序时,似乎都会出现此错误。 解决这个问题的唯一方法是重建项目并再次正常运行。 如果有人知道其原因,将不胜感激 最佳答案 尝试一下构建 -> 清理项目然后构建 -> 制
我有一个Maven Android项目,正在尝试将其转换为Gradle。我正在使用AndroidAnnotations。 在Maven项目中,我具有以下界面: @Rest(rootUrl = Cons
我正在尝试生成发布版本,但由于 mutidex 问题我无法生成我的项目已启用所有 multidex 并添加了依赖项 我收到的错误是: Execution failed for task ':app:t
很难说出这里问的是什么。这个问题是模棱两可的、模糊的、不完整的、过于宽泛的或修辞的,无法以目前的形式得到合理的回答。如需帮助澄清这个问题以便重新打开它,visit the help center .
开始新项目的最后一天,我在构建配置中创建了一些变量,作为在发布和调试构建之间单独处理它们的好习惯,如下所示: ... buildTypes { release { minify
我正在尝试生成发布版本,但由于 mutidex 问题我无法生成我的项目已启用所有 multidex 并添加了依赖项 我收到的错误是: Execution failed for task ':app:t
是否有“内置”方式将 BuildConfig 从插件共享到主机应用程序? 我们有一个使用自制插件的应用程序,我们需要将所有特殊配置(所以除了依赖项之外的所有特殊配置)设置从插件复制/粘贴到当前应用程序
当我尝试重建我的项目时,出现以下错误: warning: flag is not supported by this version of the compiler: -Xallow-no-sourc
即使经过编辑,当我建立gradle的那一刻它也会恢复。 buildConfig.java build.gradle 最佳答案 BuildConfig.java由Android构建工具生成。配置完成后,
在我的应用程序中,我需要获取应用程序版本代码和名称,因此我使用了以下语句。 obj.setCurrentVersion("APP " + String.valueOf(BuildConfig.VE
我正在开发一个多模块 Android 应用程序,一切都在 Debug模式下工作,但现在当我尝试构建发布包时,我收到此错误: Type ***module1.BuildConfig is defined
好的。这听起来好像我太沮丧了,因为我确实如此。我正在尝试构建一个 Blackberry 应用程序,以便为我工作的人发布。在添加构建配置并添加 keystore 后,我构建了 Android 系统。但是
根据Grails hibernate plugin page,休眠的范围应为compile。但是,当我创建一个新的Grails应用程序时,BuildConfig.groovy使用的是runtime范围
我有一个grails应用程序。为什么某些属性在一个属性中起作用而在另一个属性中却不起作用?何时将属性放在一个中,何时将它们放在另一个中? 最佳答案 从Grails doc here The first
好的。这听起来好像我太沮丧了,因为我确实如此。我正在尝试构建一个 Blackberry 应用程序,以便为我工作的人发布。在添加构建配置并添加 keystore 后,我构建了 Android 系统。但是
显然,从 Android SDK 17 开始,构建会生成一个名为 BuildConfig 的自动类并将其添加到我的包中。 http://android-developers.blogspot.com/
是否可以通过某种方式访问 BuildConfig.groovy 中的 Config.groovy 中指定的属性? 我在打包过程中需要复制一些引导文件,目标目录取决于指定的环境。因为我需要在应用程序
我们可以为 Config.groovy 加载不同的配置文件通过指定作为配置脚本的类。 Externalized Configuration : grails.config.locations = [c
我正在尝试使用常量 BuildConfig.class 运行 Robolectric,但它似乎不适用于 gradle 生成的所有风格。有没有命令让 gradle 为所有这些文件制作这个文件? 最佳答案
我将我的项目迁移到 Androidx,每次运行我的项目时,我都会收到此错误,提示类 BuildConfig 是公共(public)的,应在名为 BuildConfig.java 的文件中声明。我知道我
我是一名优秀的程序员,十分优秀!