Overriding GCM permission package prefix with Gradle
android, android-gradle-plugin, gradle
Solution
I've used:
<permission android:name="${applicationId}.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" />
in the Android manifest - this appears to be resolved correctly.
Problem
I have a Gradle Android project that has 4 product flavors (each has it's own unique package name). The `build.gradle` file is prity much straightforward: ``` buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.6.+' } } apply plugin: 'android' repositories { mavenCentral() } dependencies { // All dependencies here // ... } android { // Usual stuff goes here productFlavors { flav1 { packageName 'com.company.flav1' versionName calcVersion() } flav2 { packageName 'com.company.flav2' versionName calcVersion() } flav3 { packageName 'com.company.flav3' versionName calcVersion() } flav4 { packageName 'com.company.flav4' versionName calcVersion() } } // Other configurations // ... } ``` Everything goes fine, and the required resources are merged, e.t.c. Now I am trying to implement a Push Notification feature using GCM. And according to the documentation, I must declare a permission for my app, like this: ``` <permission android:name="com.company.flav.permission.C2D_MESSAGE" android:protectionLevel="signature" /> <uses-permission android:name="com.company.flav.permission.C2D_MESSAGE" /> ``` But I'm using a single manifest file, for all 4 applications (they differ only in application resources and some settings, that are put in the assets folder). So my question is: How can I override these permissions for every product flavor?