3

I'm trying to Generate APK for my App. But After Building the compiler throws an java.lang.ArrayIndexOutOfBoundsException.

I know what this Error means programatically. But If I disable the minifyEnabled to False. Then the APK is generated & the app works Fine.

I saw a similar question here & tried desugaring to false.

But Still it throws Process 'command 'C:\Program Files\Android\Android Studio\jre\bin\java.exe'' finished with non-zero exit value 1

How Can I Solve this issue ?

enter image description here

Arulnadhan
  • 923
  • 4
  • 17
  • 46

1 Answers1

4

The fix for me was to add the following to my proguard-rules.pro file:

-keepnames class com.google.android.gms.** {*;}

Something in Google Play Services plugin was causing this error for me.

If that doesn't fix it for you, you could also keepnames for anything outside of your app package by adding the following to your proguard-rules.pro file:

-keepnames class !com.yourpackage.app.** { *; }

You might also be able to use this to troubleshoot some more to figure out which class is causing the problem.

  • yes it build ok if I set `-keepnames class com.google.android.gms.** {*;}` but I don't like because it just keeps everything of that library, alternative solutions? – user155 Mar 24 '19 at 22:36
  • @user155 I found when I updated to Android Studio 3.4.1, the problem went away and I am able to remove `-keepnames class com.google.android.gms.** {*;}` I beleive in Android Studio 3.4, R8 replaces Proguard as the default code shrinker and obfuscator, which I think fixed this problem. – Hayden Campbell May 30 '19 at 05:25
  • @Hayden Campbell I had the same issue than OP and fixed it by simply enabling R8 in gradle.properties (`android.enableR8=true`). – Silas Aug 15 '19 at 20:24