Reputation: 113
Messages Gradle build:
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
Here is the gradle build files:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
minSdkVersion 26
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso
core:3.0.1'
implementation files('libs/bsh-core-2.0b4.jar')
implementation files('libs/selenium-java-2.3.0.jar')
implementation files('libs/selenium-remote-driver-3.0.0.jar')
// https://mvnrepository.com/artifact/io.appium/java-client
implementation group: 'io.appium', name: 'java-client', version: '5.0.4'
}
Upvotes: 10
Views: 18879
Reputation: 105
i had this problem using react-native with android 4.4 kit-kat, not only i had to add:
android {
defaultConfig {
...
minSdkVersion 15
targetSdkVersion 28
multiDexEnabled true
...
}
}
dependencies {
implementation 'com.android.support:multidex:2.0.1'
}
but also had to add to my MainAplication.java:
import androidx.multidex.MultiDexApplication; // <-- THIS IMPORT
and change:
public class MainApplication extends Application implements ReactApplication
to:
public class MainApplication extends MultiDexApplication implements ReactApplication
you can find more info here: https://developer.android.com/studio/build/multidex
Upvotes: 0
Reputation: 505
Add the two important line in your gradle the multidex enablity and the implementation.
android {
defaultConfig {
...
minSdkVersion 15
targetSdkVersion 28
multiDexEnabled true
}
...
}
dependencies {
implementation 'com.android.support:multidex:1.0.3'
}
Upvotes: 0
Reputation: 41
Try this on your build.gradle(Module: app)
file:
android {
defaultConfig
{
...
multiDexEnabled true
}
}
Upvotes: 3
Reputation: 59
This error is generic, can be caused by many things
java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
First, you need to know what error you have. So, you have two choices:
Next, you need to go in the part where says Cause by (Last of then because u can have more than one error).
If you have:
Caused by: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
Then you need to put this, like comments before said but if your mindSdkVersion >= 21
android {
defaultConfig
{
multiDexEnabled true
}
}
If your minSdkVersion < 21 you need put also this
compile 'com.android.support:multidex:1.0.3'
More info here
Upvotes: 4
Reputation: 933
In my case the problem were duplicate packages. I used react-native link and the app didn't recognize that packages are linked so it made duplicates of them.
Duplicate packages were generated in MainApplication.java - imports and class initialization.
Also check settings.gradle and build.gradle/app - there might be duplicate packages that will break your application as well.
Upvotes: 0