使用 Google 分析和混淆时出现构建错误

Build error when use Google Analytics and odfuscation

我在 android 遇到这个错误:

任务“:app:transformClassesWithAndroidGradleClassShrinkerForDebug”执行失败。

ProGuard configuration parser error: C:\Users\user.gradle\caches\transforms-1\files-1.1\play-services-base-11.8.0.aarc960bd35f12660f\proguard.txt line 3:88 no viable alternative at input ''

使用 minifyEnabled trueshrinkResources true

时会出现这种情况

我尝试在 proguard-rules 中保留相同的文件,但它不起作用

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

-dontwarn com.google.android.gms.**

-libraryjars /libs/libGoogleAnalytics.jar

-keep class com.google.android.apps.analytics.**{ *; }

谢谢!!

你必须。这样做至少会起作用。

buildTypes {
        release {
            debuggable false
            minifyEnabled true
            useProguard true
            ...
        }
        debug {
            debuggable true
            minifyEnabled true
            useProguard true
            ...
        }
    }