This question is the aftermath of a four day long and painful journey of consecutive attempts to overcome a appDebugAssemble failed build. I've read a super considerable amount of topics/articles that google threw at me by looking up anything with the term "multidex" but to no avail.
Recently I've started using Android Studio 3.0 Beta 4 and updated the SDK versions accordingly to Android O build release. Alongside this, I'm using AS3b4 with Gradle 4.1-all, and up to now, I was enjoying the new updates immensely.
Four days ago I decided to add Firebase Analytics and Messaging to my project and that's where it went south. For brevity, I've tried more than 30+ approaches from the suggestions (and accepted answers on SO) on how MultiDex should be configured, and since all did not make the build pass, I'm reaching a state where I'm starting to believe that there's a spell cast upon me, particularly around the time I'm about to release my app to Play Store. I've read and reread this too https://developer.android.com/studio/build/multidex.html
It goes without saying, but your shared wisdom here will be much appreciated and if a potential solution comes up, I'm very positive it'll prevent a lot of developers from going bold, or heads being banged against the wall. With that off my chest now, here's my configuration details
app.gradle
apply plugin: 'com.android.application'
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
minSdkVersion 19
targetSdkVersion 26
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
debug {
minifyEnabled false
debuggable true
useProguard false
}
}
dexOptions {
javaMaxHeapSize "4g"
preDexLibraries = false
}
dependencies {
...
implementation 'com.android.support:multidex:1.0.2'
}
apply plugin: 'com.google.gms.google-services'
The custom MyApp class
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
Looking forward to what this plentiful community of talents will have to enrich me and other fellow folks suffering from this same epidemic disease. Thank you!
EDIT: Totally forgot to paste the error log. This is what I'm faced with:
What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
Multiple dex files define {class-name}. - Alex Lipov