android studio was getting build error while build execution with following:
Error:Execution failed for task \':app:transformDexArchiveWithExternalLi
For me, adding
multiDexEnabled true
and
packagingOptions {
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/notice'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license'
exclude 'META-INF/license.txt'
}
into the app level Build.gradle file solved the issue
I tried many solutions as mentioned above including the multiDexEnabled true but none of that worked for me.
Here is the solution which worked for me - copy this code in app\build.gradle file
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support' && requested.name != 'multidex') {
details.useVersion "${rootProject.ext.supportLibVersion}"
}
}
}
Make sure to run gradlew clean before running the code