使用Gradle构建APK时,控制台出现以下错误:
如果将minifyEnabled设置为false,则错误消失。看起来存在重复的包。
:app:collectDebugMultiDexComponents
:app:transformClassesWithMultidexlistForDebug
ProGuard, version 5.2.1
Reading program jar [<My_Android_Project>/app/build/intermediates/transforms/proguard/debug/jars/3/1f/main.jar]
Reading library jar [<My_Android_SDK>/build-tools/23.0.2/lib/shrinkedAndroid.jar]
Preparing output jar [<My_Android_Project>/app/build/intermediates/multi-dex/debug/componentClasses.jar]
Copying resources from program jar [<My_Android_Project>/app/build/intermediates/transforms/proguard/debug/jars/3/1f/main.jar]
:app:transformClassesWithDexForDebug
Error:Uncaught translation error: com.android.dex.util.ExceptionWithContext: name already added: string{"a"}
Error:Uncaught translation error: com.android.dex.util.ExceptionWithContext: name already added: string{"a"}
Error:Uncaught translation error: com.android.dex.util.ExceptionWithContext: name already added: string{"a"}
Error:Uncaught translation error: com.android.dex.util.ExceptionWithContext: name already added: string{"a"}
Error:Uncaught translation error: com.android.dex.util.ExceptionWithContext: name already added: string{"a"}
Error:Uncaught translation error: com.android.dex.util.ExceptionWithContext: name already added: string{"a"}
Error:Uncaught translation error: com.android.dex.util.ExceptionWithContext: name already added: string{"a"}
Error:Uncaught translation error: com.android.dex.util.ExceptionWithContext: name already added: string{"a"}
Error:Uncaught translation error: com.android.dex.util.ExceptionWithContext: name already added: string{"a"}
Error:Error converting bytecode to dex:
Cause: java.lang.RuntimeException: Translation has been interrupted
Execution failed for task ':app:transformClassesWithDexForDebug'.
> 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 <My_JDK_PATH>/bin/java'' finished with non-zero exit value 2
build.gradle如下:
......
buildTypes {
debug {
minifyEnabled true
zipAlignEnabled false
shrinkResources false
proguardFiles 'proguard_legacy.cfg'
signingConfig signingConfigs.debug
}
release {
minifyEnabled true
zipAlignEnabled true
shrinkResources true
proguardFiles 'proguard_legacy.cfg'
signingConfig signingConfigs.release
}
}
.....
......
def dagger_version = '2.0.2'
def okhttp_version = '3.2.0'
def butterknife_version = '7.0.0'
def retrofit_version = '2.0.1'
def rxandroid_version = '1.1.0'
def rxjava_version = '1.1.0'
dependencies {
compile project(':explorer_sdk')
//multidex
compile 'com.android.support:multidex:1.0.0'
//facebook
compile 'com.facebook.android:facebook-android-sdk:4.+'
//dependency independent: dagger2/butterknife
compile "com.google.dagger:dagger:$dagger_version"
apt "com.google.dagger:dagger-compiler:$dagger_version"
compile "com.jakewharton:butterknife:$butterknife_version"
//rxjava/rxandroid
compile "io.reactivex:rxandroid:$rxandroid_version"
compile "io.reactivex:rxjava:$rxjava_version"
//retrofit2
compile "com.squareup.retrofit2:retrofit:$retrofit_version"
compile "com.squareup.retrofit2:adapter-rxjava:$retrofit_version"
compile "com.squareup.retrofit2:converter-gson:$retrofit_version"
compile "com.squareup.retrofit2:converter-jackson:$retrofit_version"
compile ("com.squareup.retrofit2:converter-simplexml:$retrofit_version") {
exclude module: 'stax-api'
exclude module: 'stax:stax'
exclude module: 'xpp3:xpp3'
}
//picasso
compile 'com.squareup.picasso:picasso:2.5.2'
//support
compile 'com.android.support:cardview-v7:23.+'
compile 'com.android.support:recyclerview-v7:23.+'
//annotation
provided 'javax.annotation:jsr250-api:1.0'
compile files('libs/ant.jar')
compile files('libs/defake.jar')
compile files('libs/HwID_OpenSDK_V3.0.01.07-R9156.jar')
compile files('libs/libammsdk_2015.2.5.jar')
compile files('libs/mta-sdk-1.6.2.jar')
compile files('libs/mtll_sdk_v115_20160226133400.jar')
compile files('libs/open_sdk_v2.9.1.jar')
compile files('libs/passportSDK_V1.4.jar')
compile files('libs/weibosdk_V3.1.jar')
compile files('libs/weibosdkcore_V3.1.jar')
//line-sdk
compile files('libs/line-android-sdk-3.1.19.jar')
}
.....
顺便问一下,如何检查重复的软件包?
name already added: string{"a"}
?你能搜索一下你的代码库,看看它是否存在于多个字符串文件或类似的地方吗? - Mostafa Berg