Android中的Firebase和唤醒锁问题 [英] Firebase and wake locks issue in Android

查看:124
本文介绍了Android中的Firebase和唤醒锁问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Android应用中使用几种Firebase产品:

I'm using several Firebase products in an Android app:

compile 'com.google.firebase:firebase-core:11.0.1'
compile 'com.google.firebase:firebase-database:11.0.1'
compile 'com.google.firebase:firebase-storage:11.0.1'
compile 'com.google.firebase:firebase-auth:11.0.1'
compile 'com.google.firebase:firebase-messaging:11.0.1'

这些产品中的一个或多个似乎正在使用WAKE_LOCK权限.可能是Analytics或FCM.

One or more of these products seems to be using the WAKE_LOCK permission. Possibly Analytics or FCM.

我知道需要什么地方.但是问题是,在Google Play控制台的Android Vitals部分中,Google警告我卡住部分唤醒锁的百分比是 2.30%,该百分比大于不良行为阈值,为 0.70%.同样,背景卡住的部分唤醒锁 1.40%,它再次大于不良行为阈值,为 0.10%.

I can understand where it's needed. The problem however is that in the Google Play Console, in the Android Vitals section, Google warns me that the Stuck partial wake locks percentage is 2.30% which is larger than the Bad behavior threshold which is 0.70%. Similarly, the Background stuck partial wake locks is 1.40% which is again larger than the Bad behavior threshold which is 0.10%.

换句话说,Google认为此唤醒锁数量是不良行为".

In other words, Google considers this number of wake locks a 'bad behavior'.

我不使用唤醒锁,因此问题似乎出在Firebase SDK上.

I don't use wake locks, so it seems that the issue is coming from the Firebase SDK.

有人知道是什么原因造成的吗?我们可以解决这个问题吗?

Anyone knows what's causing that? Can we fix that?

推荐答案

您可以使用,当您查看应用的清单文件时.在清单上查看时,您会看到WAKE_LOCK来自firebase-iid.

You can tell where Android manifest items come from by using Android Studio's Merged Manifest tab when viewing your app's manifest file. When you view this on you manifest, you'll see that WAKE_LOCK comes from firebase-iid.

要了解包括firebase-iid在内的内容,可以使用gradle显示依赖关系图.

To find out what includes firebase-iid, you can use gradle to show a dependency graph.

./gradlew dependencies

输出结果表明,firebase-core和firebase-messaging都包含它:

The output of this shows that it's included by both firebase-core and firebase-messaging:

+--- com.google.firebase:firebase-messaging:11.6.0
|    +--- com.google.firebase:firebase-iid:11.6.0
|    |    +--- com.google.android.gms:play-services-basement:11.6.0 (*)
|    |    +--- com.google.firebase:firebase-common:11.6.0 (*)
|    |    +--- com.google.android.gms:play-services-tasks:11.6.0 (*)
|    |    \--- com.google.firebase:firebase-iid-license:11.6.0
|    +--- com.google.android.gms:play-services-basement:11.6.0 (*)
|    +--- com.google.firebase:firebase-common:11.6.0 (*)
|    \--- com.google.firebase:firebase-messaging-license:11.6.0
\--- com.google.firebase:firebase-core:11.6.0
     \--- com.google.firebase:firebase-analytics:11.6.0
          +--- com.google.android.gms:play-services-basement:11.6.0 (*)
          +--- com.google.firebase:firebase-common:11.6.0 (*)
          +--- com.google.firebase:firebase-analytics-impl:11.6.0
          |    +--- com.google.android.gms:play-services-basement:11.6.0 (*)
          |    +--- com.google.firebase:firebase-iid:11.6.0 (*)
          |    +--- com.google.firebase:firebase-common:11.6.0 (*)
          |    +--- com.google.android.gms:play-services-tasks:11.6.0 (*)
          |    \--- com.google.firebase:firebase-analytics-impl-license:11.6.0
          \--- com.google.firebase:firebase-analytics-license:11.6.0

这里没有什么需要修复"的. Firebase仅利用唤醒锁来完成其正常业务.您随时可以尝试删除权限,但是Firebase可能无法再正常工作.别管它.

There is nothing here that needs to be "fixed". Firebase simply makes use of wake locks to do its normal business. You can always try to remove the permission, but then Firebase may not work correctly any more. Just leave it alone.

这篇关于Android中的Firebase和唤醒锁问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆