To build apk with gradle, error in console as following:
if make minifyEnabled = false, error disappear. It looks like there are duplicated packages.
: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 as following:
......
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')
}
.....
By the way, how to check which package is duplicated?
By default, the Gradle build creates two . apk files in the build/outputs/apk folder. To build and start your unit tests on the JVM use the following command. To build and start your instrumented tests on your Android device use the following command.
Android Studio uses Gradle, an advanced build toolkit, to automate and manage the build process, while allowing you to define flexible custom build configurations. Each build configuration can define its own set of code and resources, while reusing the parts common to all versions of your app.
It could be that you are using gradle in offline mode. To uncheck it go to File > Settings > Gradle , uncheck the Offline Work checkbox, and click Apply Make sure you have internet connection and sync the project again.
Flutter is an open source framework developed by Google that lets you build natively compiled, multiplatform applications from a single codebase. Flutter 3 supports six platform targets: Android, iOS, Windows, macOS, Linux, and web applications.
Try to add below gradle options in your build.gradle. By adding below options, you can enable MultiDex support and incremental dex support.
...
defaultConfig {
...
multiDexEnabled true // Enabling multidex support.
}
...
dexOptions {
//you can speed up your builds by turning on incremental dexing
incremental = true;
//you can specify the heap size for the dex process
javaMaxHeapSize "4g"
}
In your app extends the Application
class, you can override the attachBaseContext()
method and call MultiDex.install(this)
to enable multidex.
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
Also you can see below related question links on stackoverflow:
Error:Execution failed for task ':app:transformClassesWithDexForDebug'. > com.android.build.api.transform.TransformException:..non-zero exit value 3
Android java.exe finished with non-zero exit value 1
See Building Apps with Over 65K Methods
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With