0

I am trying to generate a signed apk of my app and I receive the following error

Error:Error converting bytecode to dex: Cause: com.android.dex.DexException: Too many classes in --main-dex-list, main dex capacity exceeded

Error:Execution failed for task ':app:transformClassesWithDexForRelease'. com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Error while executing java process with main class com.android.dx.command.Main with arguments {--dex --force-jumbo --num-threads=4 --multi-dex --main-dex-list C:\Users\user\Desktop\Mystuff\GetALifFitness\WonderStree-Production\app\build\intermediates\multi-dex\release\maindexlist.txt --output C:\Users\user\Desktop\Mystuff\GetALifFitness\WonderStree-Production\app\build\intermediates\transforms\dex\release\folders\1000\1f\main C:\Users\user\Desktop\Mystuff\GetALifFitness\WonderStree-Production\app\build\intermediates\transforms\proguard\release\jars\3\1f\main.jar}

I have tried some of the solutions to this from this link Too many classes in --main-dex-list, main dex capacity exceeded But it does not work for me. Can you guys please suggest me what could be wrong or provide me with the solution? Thank you.

What I have already tried - This is how my proguard file looks like:

-keepclassmembers class toan.android.floatingactionmenu.FloatingActionsMenu$RotatingDrawable { void set*(***);   *** get*(); }

-ignorewarnings

-keep class * {    public private *; }

-dontwarn okio.**

-keep public class com.google.android.gms.* { public *; }
-dontwarn com.google.android.gms.**

-dontwarn com.mixpanel.**

And build.gradle file I added:

dexOptions {
        javaMaxHeapSize "4g"
        keepRuntimeAnnotatedClasses false
}

Also, I removed the unwanted libraries. Yet this problem is not solved.

ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96
  • "But it does not work for me" -- please provide a [mcve] demonstrating what you tried and explain, in detail, what "does not work for me" means. – CommonsWare Oct 14 '17 at 17:03
  • I added this to my proguard file - -keepclassmembers class toan.android.floatingactionmenu.FloatingActionsMenu$RotatingDrawable { void set*(***); *** get*(); } -ignorewarnings -keep class * { public private *; } -dontwarn okio.** -keep public class com.google.android.gms.* { public *; } -dontwarn com.google.android.gms.** -dontwarn com.mixpanel.** And I also tried to remove the unused packages and libraries from my app and included this too - dexOptions { keepRuntimeAnnotatedClasses false } But none of this works. I don't understand what is causing this error – neeraj Saxena Oct 14 '17 at 17:19

1 Answers1

1

I solved the issue by removing this particular line from build.gradle file

multiDexKeepProguard file('proguard-rules.pro')

This is how my build.gradle file looks now

buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        ext.enableCrashlytics = true
    }
}