0

I'm Using FCM with Dexguard. FCM cannot make token in release build. but, it works well in debug build.

my gradle settings

classpath 'com.google.gms:google-services:3.2.1'
compile 'com.google.android.gms:play-services-base:15.0.2'
compile 'com.google.android.gms:play-services-analytics:15.0.2'
compile 'com.google.firebase:firebase-core:15.0.2'
compile 'com.google.firebase:firebase-messaging:15.0.2'

And, ShrinkResources = false And optimize 5time by Dexguard

gradle version : 4.1 android gradle plugin : 2.3.3

options in dexguardFile related with FCM

-keep public class com.google.firebase.** { *; }
-keep public class com.google.firebase.iid.FirebaseInstanceId { public *;}
  • You could try the latest versions of the plugins: [com.google.gms:google-services:3.3.1](https://developers.google.com/android/guides/google-services-plugin) and [com.android.tools.build:gradle:3.1.0](https://developer.android.com/studio/releases/gradle-plugin#3-1-0). – Bob Snyder May 14 '18 at 13:50
  • okay, I'll try it – Kyeongrae Cho May 16 '18 at 06:40
  • @KyeongraeCho: Did you fix the problem? I have exactly the same problem. The Method onTokenRefresh() of FirebaseInstanceIdService will not get called in release version with dexguard, only in debug version. All Libraries up to date. – user2082415 Jun 19 '18 at 07:37
  • @user2082415 I cannot fix it yet. – Kyeongrae Cho Jun 20 '18 at 08:26

3 Answers3

1

Firebase 15+ requires some additional rules. The latest DexGuard version 8.2.09 for example includes all necessary configurations.

T. Neidhart
  • 6,060
  • 2
  • 15
  • 38
0

Add the following dexguard rules to fix the problem:

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

It seems that dexguard removes all classes that are not directly referenced in code. So the entry points like services classes to get firebase tokens (FirebaseInstanceIdService) will be removed during obfuscation process, if shrinking is allowed.

user2082415
  • 200
  • 1
  • 2
  • 7
0

I had similar issues with Firebase analytics where it works for debug build but not the release build, thanks to T. Neidhart's answer above I found this block from the Dexguard 8.4.13 sample - samples/advanced/GooglePlayServices/AdMob/dexguard-project.txt and it solves the problem for me.

-keep public class !**.internal.**, com.google.** {
    public protected *;
}
# We can repackage all obfuscated classes in a new internal package.
-repackageclasses com.google.internal
Alex
  • 51
  • 1
  • 5