Search code examples
androidfirebase-authenticationbuild.gradleproguardminify

Long Android build times hanging on minify


Recently I've been expanding my project to include com.google.firebase:firebase-auth:19.3.0 functionality. As a result I've encountered following error: Cannot fit requested classes in a single dex file (# methods: 112748 > 65536). The solution was to make my project multiDexEnabled as I'm using minSdkVersion 16.

The problem I'm facing now is the building time which seems to have no end (I've cancelled it out after 5 minutes). This happens when minifyEnabled is turned on. The dependencies I'm using within my project are shown below. Any ideas why minify takes so much time?

    implementation 'com.android.billingclient:billing:2.2.0'
    implementation 'com.google.android.ads.consent:consent-library:1.0.8'
    implementation 'com.google.android.gms:play-services-auth:17.0.0'
    implementation 'com.google.android.gms:play-services-games:19.0.0'
    implementation 'com.google.android.gms:play-services-instantapps:17.0.0'
    implementation 'com.google.firebase:firebase-analytics:17.2.3'
    implementation 'com.google.firebase:firebase-auth:19.3.0'
    implementation 'com.google.firebase:firebase-firestore:21.4.1'
    implementation 'androidx.versionedparcelable:versionedparcelable:1.1.0'
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.multidex:multidex:2.0.1'

Solution

  • Add the below lines in your gradle.properties and then see the results

    org.gradle.daemon=true
    org.gradle.caching=true
    org.gradle.parallel=true
    org.gradle.configureondemand=true
    org.gradle.jvmargs=-Xmx3096M -XX:MaxPermSize=1024m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8