将minifyEnabled设置为true后,我收到以下错误

时间:2016-08-23 10:33:03

标签: android firebase google-play-services proguard firebase-authentication

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: in.pharmaz.partner, PID: 26775
    java.lang.RuntimeException: Unable to start activity ComponentInfo{in.pharmaz.partner/in.pharmaz.partner.SplashScreenActivity}: java.lang.ClassCastException: com.google.android.gms.internal.zzald cannot be cast to com.google.firebase.auth.UserInfo
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
        at android.app.ActivityThread.-wrap11(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:148)
        at android.app.ActivityThread.main(ActivityThread.java:5417)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
    Caused by: java.lang.ClassCastException: com.google.android.gms.internal.zzald cannot be cast to com.google.firebase.auth.UserInfo
        at com.google.android.gms.internal.zzadh.zzN(Unknown Source)
        at com.google.firebase.auth.FirebaseAuth.zza(Unknown Source)
        at com.google.firebase.auth.FirebaseAuth.zzOj(Unknown Source)
        at com.google.firebase.auth.FirebaseAuth.<init>(Unknown Source)
        at com.google.firebase.auth.FirebaseAuth.<init>(Unknown Source)
        at com.google.android.gms.internal.zzadg.<init>(Unknown Source)
        at com.google.firebase.auth.FirebaseAuth.zzc(Unknown Source)
        at com.google.firebase.auth.FirebaseAuth.zzb(Unknown Source)
        at com.google.firebase.auth.FirebaseAuth.getInstance(Unknown Source)
        at in.pharmaz.partner.SplashScreenActivity.onCreate(SplashScreenActivity.java:38)
        at android.app.Activity.performCreate(Activity.java:6251)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
        at android.app.ActivityThread.-wrap11(ActivityThread.java) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:148) 
        at android.app.ActivityThread.main(ActivityThread.java:5417) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

SplashScreenActivity第38行是:

firebaseAuth = FirebaseAuth.getInstance();

我的ProGuard规则包含:

-keep class com.google.** {*;}

我试着到处搜寻,什么也没找到。

我的build.gradle

 buildTypes {
    release {
        minifyEnabled true
        shrinkResources true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        signingConfig signingConfigs.config
        proguardFile 'C:/Users/vikas/Desktop/phzVendor/phzandvendor/app/proguard-rules.pro'
    }
    debug {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        debuggable true
        signingConfig signingConfigs.config
        proguardFile 'C:/Users/vikas/Desktop/phzVendor/phzandvendor/app/proguard-rules.pro'
    }
}

1 个答案:

答案 0 :(得分:3)

如果将minifyEnabled设置为true,则表示proguard启动正常。 您需要为每个lib和应用程序提供正确的proguard配置。

对于firebase,您可以找到配置hereofficial docs

here is一个项目,为proguard配置收集许多有用的片段。