本文介绍了Firebase + Proguard/R8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在我的项目中设置Firebase(FCM),并且当我运行混淆了R8的应用程序时遇到了问题,Firebase服务(FirebaseMessagingService)不再起作用.有没有人遇到过同样的问题?有解决办法吗?

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 :最后,我通过降级到

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 :在使用最新版本的库运行混淆的应用程序时,我还注意到了日志中的警告:

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.

推荐答案

终于解决了这个问题,接下来的proguard规则对我来说是个窍门:

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

这篇关于Firebase + Proguard/R8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-17 05:06
查看更多