androidxandroid-studio-3.4

Android Studio stuck on :app:transformdexarchivewithdexmergerfordebug after migrating to androidx while building the gradle


I migrated to AndroidX and since then I'm unable to run my app on emulator neither I'm able to generate .apk or app bundle because the android studio gets stuck on

:app:transformdexarchivewithdexmergerfordebug while building the app.

I tried to remove multidex and enabling it, still found no luck

This is my app gradle file

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'com.google.firebase.firebase-perf'

android {
compileSdkVersion 28
buildToolsVersion '28.0.3'

defaultConfig {
    applicationId "com.example"
    minSdkVersion 21
    targetSdkVersion 28
    versionCode 100
    versionName "1.0.0"
    vectorDrawables.useSupportLibrary = true
    multiDexEnabled true
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

lintOptions {
    checkReleaseBuilds false
    // Or, if you prefer, you can continue to check for errors in release builds,
    // but continue the build even when errors are found:
    abortOnError false
}

}

dependencies {
def lifecycle_version = "1.1.1"
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:support-annotations:28.0.0'
implementation 'com.google.firebase:firebase-core:17.0.0'
implementation 'com.google.firebase:firebase-messaging:19.0.1'
implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'com.google.android.gms:play-services-places:17.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'com.github.deano2390:MaterialShowcaseView:1.2.0'
implementation 'com.github.deano2390:MaterialShowcaseView:1.2.0@aar'
implementation 'com.github.amlcurran.showcaseview:library:5.4.3'
implementation 'com.github.iammert:MaterialIntroView:1.5.2'
implementation 'com.github.mreram:showcaseview:1.1'
implementation 'id.zelory:compressor:2.1.0'
implementation 'com.github.hkk595:Resizer:v1.5'
implementation 'com.google.android.gms:play-services-auth:17.0.0'
implementation 'com.google.firebase:firebase-auth:18.0.0'
implementation 'com.google.firebase:firebase-database:18.0.0'
implementation 'com.google.firebase:firebase-storage:18.0.0'
implementation "com.google.android.gms:play-services-auth-api-phone:17.0.0"
implementation 'com.firebaseui:firebase-ui-auth:3.2.2'
implementation 'com.firebaseui:firebase-ui-database:4.2.1'
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
implementation 'com.android.support:design:27.0.2'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.facebook.android:facebook-login:4.35.0'
implementation 'com.twitter.sdk.android:twitter:3.1.1'
implementation 'com.twitter.sdk.android:twitter-mopub:3.1.1'
implementation 'com.twitter.sdk.android:twitter-core:3.1.1'
implementation "android.arch.lifecycle:extensions:$lifecycle_version"
implementation group: 'androidx.lifecycle', name: 'lifecycle-viewmodel-ktx', version: '2.1.0-alpha04'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.facebook.android:account-kit-sdk:4.39.0'
implementation name: 'sinch-android-verification-1.6.0', ext: 'aar'
implementation 'com.github.joielechong:countrycodepicker:2.3.0'
implementation 'com.github.bumptech.glide:glide:4.9.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
implementation 'com.google.firebase:firebase-ads:18.0.0'
implementation 'com.google.android.gms:play-services-ads:18.0.0'
implementation 'com.firebase:firebase-client-android:2.5.0'
implementation 'com.iceteck.silicompressorr:silicompressor:2.2.2'
implementation 'com.google.android.exoplayer:exoplayer:2.7.2'
// Add the dependency for the Performance Monitoring library
implementation 'com.google.firebase:firebase-perf:18.0.1'
implementation 'com.instabug.library:instabug:8.4.0'

}
apply plugin: 'com.google.gms.google-services'

I've tried invalidating caches and restart and also deleted the cache in .gradle/caches/ but still, the problem persists. Android studio stuck on :app:transformdexarchivewithdexmergerfordebug since 3 hours and not building the project.

Could someone please help me what can I do so that my project build successfully?


Solution

  • I fixed this yesterday on my project. When you build from the command line with --debug or --stacktrace, you'll find that Gradle runs out of memory. My javaMaxHeapSize was set to 8g, but that didn't seem to work (or matter).

    Setting it to 2048M and removing com.google.firebase:firebase-perf seemed to do the trick. I'll suggest you set your javaMaxHeapSize in dexOptions to 2048M and try building.