其他分享
首页 > 其他分享> > android – Firebase Analytics和崩溃的权限

android – Firebase Analytics和崩溃的权限

作者:互联网

我用了

//Analytics
compile 'com.google.firebase:firebase-core:9.2.1'
// Crash
compile 'com.google.firebase:firebase-crash:9.2.1'

并在我生成的清单中获得了那些人:

<!-- Required permission for App measurement to run. -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- Optional permission for App measurement to run. -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />

然后我们有以下块

<permission
    android:name="my.package.name.permission.C2D_MESSAGE"
    android:protectionLevel="signature" />
<uses-permission android:name="my.package.name.permission.C2D_MESSAGE" />

我的问题:

If I use only Firebase Analytics and Crash and don’t need any messaging functional, is it Ok to remove the second block as follows:

<uses-permission android:name="my.package.name.permission.C2D_MESSAGE" tools:node="remove" />

What does it mean “Optional permission for App measurement to run” in the first block? Is it safe to remove that too?

解决方法:

Firebase Analytics使用FirebaseInstanceId.通过在Gradle的Android Studio工具窗口中运行依赖项任务可以看到这一点.输出的这一部分显示了对FirebaseInstanceId的依赖:

+--- com.google.firebase:firebase-core:9.2.1
|    \--- com.google.firebase:firebase-analytics:9.2.1
|         +--- com.google.android.gms:play-services-basement:9.2.1
|         |    \--- com.android.support:support-v4:24.1.0
|         |         \--- LOCAL: internal_impl-24.1.0.jar
|         +--- com.google.firebase:firebase-common:9.2.1
|         |    +--- com.google.android.gms:play-services-basement:9.2.1
|         |    |    \--- com.android.support:support-v4:24.1.0
|         |    |         \--- LOCAL: internal_impl-24.1.0.jar
|         |    \--- com.google.android.gms:play-services-tasks:9.2.1
|         |         \--- com.google.android.gms:play-services-basement:9.2.1
|         |              \--- com.android.support:support-v4:24.1.0
|         |                   \--- LOCAL: internal_impl-24.1.0.jar
|         \--- com.google.firebase:firebase-analytics-impl:9.2.1
|              +--- com.google.android.gms:play-services-basement:9.2.1
|              |    \--- com.android.support:support-v4:24.1.0
|              |         \--- LOCAL: internal_impl-24.1.0.jar
|              +--- com.google.firebase:firebase-iid:9.2.1  <== FirebaseInstanceId
|              |    +--- com.google.android.gms:play-services-basement:9.2.1
|              |    |    \--- com.android.support:support-v4:24.1.0
|              |    |         \--- LOCAL: internal_impl-24.1.0.jar
|              |    \--- com.google.firebase:firebase-common:9.2.1
|              |         +--- com.google.android.gms:play-services-basement:9.2.1
|              |         |    \--- com.android.support:support-v4:24.1.0
|              |         |         \--- LOCAL: internal_impl-24.1.0.jar
|              |         \--- com.google.android.gms:play-services-tasks:9.2.1
|              |              \--- com.google.android.gms:play-services-basement:9.2.1
|              |                   \--- com.android.support:support-v4:24.1.0
|              |                        \--- LOCAL: internal_impl-24.1.0.jar
|              \--- com.google.firebase:firebase-common:9.2.1
|                   +--- com.google.android.gms:play-services-basement:9.2.1
|                   |    \--- com.android.support:support-v4:24.1.0
|                   |         \--- LOCAL: internal_impl-24.1.0.jar
|                   \--- com.google.android.gms:play-services-tasks:9.2.1
|                        \--- com.google.android.gms:play-services-basement:9.2.1
|                             \--- com.android.support:support-v4:24.1.0
|                                  \--- LOCAL: internal_impl-24.1.0.jar

C2D_MESSAGE权限来自与firebase-iid库关联的清单.我的猜测是,如果没有它,FirebaseAnalytics将无法获取设备的唯一ID,也无法报告数据.

关于WAKE_LOCK权限,请参阅此related answer.

我怀疑删除任何权限是安全的.您可以通过在没有它们的情况下运行并查看分析是否报告任何事件来查找.

标签:android,firebase,firebase-analytics,firebase-crash-reporting
来源: https://codeday.me/bug/20190608/1199611.html