Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Permission name C2D_MESSAGE is not unique appears in both C2D_MESSAGE

I'm getting this error:

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)

enter image description here

In my Android manifest:

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

The problem started after adding the applicationIdSuffix to a flavor in build.gradle (which at first glance seemed to have nothing to do with it).

Build.gradle:

flavorDimensions "type"
productFlavors {
    acceptance {
        dimension="type"
        applicationIdSuffix ".acc"
        versionNameSuffix "-acc"
    }
    production {
        dimension="type"
        applicationIdSuffix ""
        versionNameSuffix ""
    }
}

Application.java:

    if (BuildConfig.DEBUG) {
        GoogleAnalytics.getInstance(context).setDryRun(true);
    } else {
        setupGoogleAnalytics();
    }

I've created a copy of google-services.json.

I've added google-services.json to:

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

 app\src\production\google-services.json

I've made different bogus values for the keys in the acceptance. I don't want Google Analytics in the acceptance version. So I prefer to not create a separate google-services.json. Is this possible?

Simply removing the permission in manifest doesn't work for API<23.

like image 510
Jim Clermonts Avatar asked Apr 12 '18 11:04

Jim Clermonts


1 Answers

This looks like you're using the latest Firebase Cloud Messaging (FCM) SDK but retaining the old GCM permissions. The FCM SDK automatically injects the necessary permissions into your manifest at build time.

Remove the C2D_MESSAGE permission from your manifest per the migration guide here: https://developers.google.com/cloud-messaging/android/android-migrate-fcm

like image 154
Larry Schiefer Avatar answered Nov 15 '22 04:11

Larry Schiefer