问题
My project is built fine with debug build variant, but with release variant Android Studio throws:
Caused by: java.lang.ArrayIndexOutOfBoundsException: 213
What could be the issue?
If I set minifyEnabled false
in build gradle for release build variant then it is being built ok, but it's not good
Update
I tried to add to proguard-rules.pro
-keepnames class com.google.android.gms.** {*;}
And it builds but I don't like this solution, I don't want to keep everything of that com.google.android.gms
...
Any good solution?
p.s. I use classpath 'com.google.gms:google-services:4.2.0'
it root build.gradle as a dependency
Update 2
Now it started to throw Execution failed for task ':app:transformClassesWithDexBuilderForRelease'.
Multi Dex library is used of course (I'm targeting Android API 14+)
回答1:
I solved it by updating to Android Studio 3.4 RC 2 which uses R8 by default instead of Proguard
Now build variant with minifyEnabled true
works fine
Seems R8 can be used with Stable AS 3.3 too but it needs some configuration: https://android-developers.googleblog.com/2018/11/r8-new-code-shrinker-from-google-is.html
来源:https://stackoverflow.com/questions/55329060/android-build-release-failed-with-caused-by-java-lang-arrayindexoutofboundsexce