Warm tip: This article is reproduced from stackoverflow.com, please click
android firebase firebase-cloud-messaging android-r8

Firebase + Proguard/R8

发布于 2020-03-28 23:16:32

I am currently working on setting up Firebase (FCM) in my project and have encountered a problem when I run my R8-obfuscated app, the Firebase service (FirebaseMessagingService) no longer works. Has anyone encountered the same problem? Any solution?

UPD: Finally I fixed it for FCM by downgrading to

com.google.firebase:firebase-messaging:15.0.0

There are some deprecated classes in use now but it works.

UPD2: While running obfuscated app with the newest versions of libraries I also noticed warnings in the logs:

W/FA: Failed to retrieve Firebase Instance Id

This is most likely the root of the problem.

Questioner
Maksim Sukhotski
Viewed
192
Maksim Sukhotski 2020-02-20 07:46

Finally got it fixed, next proguard rules did a trick for me:

# Firebase
-keep class com.google.android.gms.** { *; }
-keep class com.google.firebase.** { *; } // especially this one