APP 发布时出现 Proguard 错误 - android/arch/core/internal/SafeIterableMap

Proguard error on APP release - android/arch/core/internal/SafeIterableMap

Proguard 在优化应用程序后失败并显示此消息。

compileSdkVersion = 27

buildToolsVersion = "27.0.3"

minSdkVersion = 16

targetSdkVersion = 27

Shrinking... Removing unused program classes and class elements... Original number of program classes: 6833 Final number of program classes: 6348 Optimizing... Unexpected error while computing stack sizes: Class = [android/arch/core/internal/SafeIterableMap] Method = [zzf(Ljava/lang/String;)J] Exception = [java.lang.IllegalArgumentException] (Stack size becomes negative after instruction [24] invokestatic #4625 in [android/arch/core/internal/SafeIterableMap.zzf(Ljava/lang/String;)J]) Warning: Exception while processing task java.io.IOException: java.lang.IllegalArgumentException: Stack size becomes negative after instruction [24] invokestatic #4625 in [android/arch/core/internal/SafeIterableMap.zzf(Ljava/lang/String;)J] Thread(Tasks limiter_5): destruction :app:transformClassesAndResourcesWithProguardForRelease FAILED

在我的例子中,我通过在 proguard 文件中注释这些行来解决这个问题:

#-assumenosideeffects class android.util.Log {
#    public static *** d(...);
#    public static *** v(...);
#    public static *** i(...);
#    public static *** w(...);
#    public static *** e(...);

我最终对每个日志都使用了 if(BuildConfig.DEBUG)