权限名称 C2D_MESSAGE 不是唯一的,同时出现在 C2D_MESSAGE 中

Jim*_*nts 5 android google-play-services

我收到此错误:

Permission name C2D_MESSAGE is not unique (appears in both my.packagename.permission.C2D_MESSAGE and my.packagename.acc.permission.C2D_MESSAGE) (Previous permission here)
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

在我的 Android 清单中:

<permission
    android:name="my.packagename.permission.C2D_MESSAGE"
    android:protectionLevel="signature" />
<uses-permission android:name="my.packagename.permission.C2D_MESSAGE" />
Run Code Online (Sandbox Code Playgroud)

问题是在将 applicationIdSuffix 添加到 build.gradle 中的一个风味之后开始的(乍一看似乎与它无关)。

构建.gradle:

flavorDimensions "type"
productFlavors {
    acceptance {
        dimension="type"
        applicationIdSuffix ".acc"
        versionNameSuffix "-acc"
    }
    production {
        dimension="type"
        applicationIdSuffix ""
        versionNameSuffix ""
    }
}
Run Code Online (Sandbox Code Playgroud)

应用程序.java:

    if (BuildConfig.DEBUG) {
        GoogleAnalytics.getInstance(context).setDryRun(true);
    } else {
        setupGoogleAnalytics();
    }
Run Code Online (Sandbox Code Playgroud)

我创建了google-services.json的副本。

我已将 google-services.json 添加到:

 app\src\acceptance\google-services.json (fake numbers)

 app\src\production\google-services.json
Run Code Online (Sandbox Code Playgroud)

我为接受中的键设置了不同的虚假值。我不希望在接受版本中使用 Google Analytics。所以我不想创建单独的 google-services.json。这可能吗?

简单地删除 清单中的权限不适用于 API<23。

Lar*_*fer 2

您似乎正在使用最新的 Firebase Cloud Messaging (FCM) SDK,但保留了旧的 GCM 权限。FCM SDK 在构建时自动将必要的权限注入到您的清单中。

根据此处的迁移指南从清单中删除 C2D_MESSAGE 权限:https ://developers.google.com/cloud-messaging/android/android-migrate-fcm