首页 > 解决方案 > Android 构建发布失败,原因是:java.lang.ArrayIndexOutOfBoundsException: 213(pr​​oguard 问题)

问题描述

我的项目使用调试构建变体构建得很好,但使用发布变体 Android Studio 会抛出:

引起:java.lang.ArrayIndexOutOfBoundsException:213

在此处输入图像描述

在此处输入图像描述

可能是什么问题?

如果我minifyEnabled false在 build gradle 中设置发布版本变体,那么它正在构建中,但它并不好

更新

我试图添加到proguard-rules.pro -keepnames class com.google.android.gms.** {*;}

它建立了,但我不喜欢这个解决方案,我不想保留所有这些com.google.android.gms......

有什么好的解决办法吗?

ps 我使用classpath 'com.google.gms:google-services:4.2.0'它 root build.gradle 作为依赖

更新 2

现在它开始抛出Execution failed for task ':app:transformClassesWithDexBuilderForRelease'.

当然使用了 Multi Dex 库(我的目标是 Android API 14+)

标签: androidandroid-studioandroid-gradle-pluginbuild.gradle

解决方案


我通过更新到默认使用R8而不是Proguard的 Android Studio 3.4 RC 2 解决了这个问题

现在构建变体minifyEnabled true工作正常

似乎R8也可以与 Stable AS 3.3 一起使用,但它需要一些配置:https ://android-developers.googleblog.com/2018/11/r8-new-code-shrinker-from-google-is.html


推荐阅读