1
votes

I'm trying to enable Proguard with react-native-firebase freshly installed on my android project.

However I have an error from Proguard that I can't get rid of.

Warning: io.invertase.firebase.messaging.RNFirebaseMessagingService: can't find referenced method 'android.content.Context getApplicationContext()' in program class io.invertase.firebase.messaging.RNFirebaseMessagingService

I've tried to add the following, but it didn't work:

-keep public class android.content.Context

and this:

-keep public class android.content.* { public *; }
-dontwarn android.content.*

Those are the other things I've added to my Proguard file, the rest is from react-native. It looks like this:

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

-keep public class com.google.firebase.* { public *; }
-dontwarn com.google.firebase.**

-keep public class me.leolin.shortcutbadger.* { public *; }
-dontwarn me.leolin.shortcutbadger.**

Any idea how I could get rid of this warning?

Thanks

2

2 Answers

1
votes

Same issue here - react-native+dependencies+gradle+pro-guard = dream team.. every build a new surprise.

Helped me for now:

-keep class io.invertase.firebase.messaging.** { *; }
-dontwarn io.invertase.firebase.messaging.**
0
votes

Maybe you need to add also google play service.

# Google Play Services
-keep class com.google.android.gms.** { *; }
-dontwarn com.google.android.gms.**
-keep class com.google.firebase.** { *; }
-dontwarn com.google.firebase.**