作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我有一个应用程序,其中有本地单元测试(测试文件夹)和仪器单元测试用例(androidTest 文件夹)。现在,如果我点击 androidTest 文件夹,然后点击“运行所有测试”,它会抛出以下异常。
Error:Error converting bytecode to dex:
Cause: com.android.dex.DexIndexOverflowException: field ID not in [0, 0xffff]: 65536
Error:Execution failed for task ':news-app:transformClassesWithDexForDebugAndroidTest'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 2
这个异常显然是因为达到 multidex 限制。但是我已经为调试构建启用了 multi-dex
。我想当仪器测试用例运行时,它们是在 Debug模式下运行的。那为什么会出现这个异常呢?
我正在附加 build.gradle 文件
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
compileSdkVersion 22
buildToolsVersion 22.0.1
defaultConfig {
minSdkVersion 14
targetSdkVersion 22
applicationId "com.xyz"
}
buildTypes {
debug {
minifyEnabled false
shrinkResources false
multiDexEnabled true
}
release {
minifyEnabled true
shrinkResources true
multiDexEnabled false
}
}
lintOptions {
warning 'InvalidPackage', 'GradleCompatible'
}
dexOptions {
preDexLibraries true
incremental true
jumboMode = true
javaMaxHeapSize "4g"
}
}
}
}
最佳答案
让这个工作。我在 app
模块的 build.gradle
中设置了 multiDexEnabled true
。但是我在其他一些模块中运行单元测试。事实证明,我还需要在该模块中添加 multiDexEnabled true
。
android {
buildTypes {
debug {
multiDexEnabled true
}
}}
关于android - 运行单元测试用例时达到 Multidex 限制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37001283/
我最近购买了《C 编程语言》并尝试了 Ex 1-8这是代码 #include #include #include /* * */ int main() { int nl,nt,nb;
早上好!我有一个变量“var”,可能为 0。我检查该变量是否为空,如果不是,我将该变量保存在 php session 中,然后调用另一个页面。在这个新页面中,我检查我创建的 session 是否为空,
我正在努力完成 Learn Python the Hard Way ex.25,但我无法理解某些事情。这是脚本: def break_words(stuff): """this functio
我是一名优秀的程序员,十分优秀!