android studio was getting build error while build execution with following:
Error:Execution failed for task \':app:transformDexArchiveWithExternalLi
I was receiving the same error and in my case, the error was resolved when I fixed a build error which was associated with a different build variant than the one I was currently building.
I was building the build variant I was looking at just fine with no errors, but attempting to debug caused a app:transformDexArchiveWithExternalLibsDexMergerForDebug
error. Once I switched to build the other build variant, I caught my error in the build process and fixed it. This seemed to resolve my app:transformDexArchiveWithExternalLibsDexMergerForDebug
issue for all build variants.
Note that this error wasn't within the referenced external module but within a distinct source set of a build variant which referenced an external module. Hope that's helpful to someone who may be seeing the same case as me!
When the version of Android Studio is 3.0.1, Gradle Version is 4.1 and Android PluginVersion is 3.0.0, it will encounter this problem. Then I downgrade Gradle Version is 3.3, Android Android is zero, there is no such problem.
Go to your module level build.gradle
file and add the following lines to the code
defaultConfig {
...
minSdkVersion 15
targetSdkVersion 28
multiDexEnabled true
}
...
}
dependencies {
implementation 'com.android.support:multidex:1.0.3'
}
That solved the problem easily. Check this documentation
To remove this Dex issue just implement one dependency. This issue occur when we are using multiple different service from the same server. Suppose we are using ads and Firestore in a project and both have a repository maven. so we need to call different data with on repository we need dex dependency to implement. The new update Dependency:-
implementation 'com.android.support:multidex:1.0.3'
I'm sure it will resolve your issue permanent
I also got the similar error.
Problem :
Solution :
Main root cause for this issue ismultiDex is not enabled. So in the Project/android/app/build.gradle, enable the multiDex
For further information refer the documentation: https://developer.android.com/studio/build/multidex#mdex-gradle
Use multiDexEnabled true as below.
{
minSdkVersion 17
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
and
implementation 'com.android.support:multidex:1.0.3'
this Solution worked for me.