1

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.

  • 1
    Your relevant build.gradle entries, proguard/r8 config and the errors you are getting would help probably. – SebRut Jan 31 '20 at 09:55
  • 1
    @SebRut this is reproducable with the basic FCM configuration [recommended by Google](https://firebase.google.com/docs/cloud-messaging/android/client). I started a new Android Studio project and integrated Firebase in it but the problem still exists, obfuscated build is not visible to Firebase console and I just can`t finish the last step of Firebase setup. And since the R8 obfuscation mechanism gets the rules from the library itself, proguard configuration files are no longer needed. – Maksim Sukhotski Jan 31 '20 at 11:35

3 Answers3

12

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
0

Just see the complaints R8 throws in the build log ...and do as the say. Only because it might provide configuration for the library itself, does not imply it provides configuration for your application code. Also make sure to have the fingerprint of the release key added in the Firebase console.

Martin Zeitler
  • 1
  • 19
  • 155
  • 216
0

In my case I broke it myself.

While setting up obfuscation I turned on debug mode for testing

release {
    debuggable true
}

And with combination of

FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(!BuildConfig.DEBUG)

it was bound to fail, don't be me :)

solidogen
  • 591
  • 5
  • 12