重写GCM许可包preFIX与摇篮 [英] Overriding GCM permission package prefix with Gradle
问题描述
我有一个摇篮的Android项目,有4个产品口味(每个都有它自己独特的包名)。该 build.gradle
文件prity多简单:
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
// ...
}
一切顺利,以及所需的资源合并等现在,我想实现使用GCM推送通知功能。而根据该文件,我必须声明同意我的应用程序,像这样的:
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" />
但我使用一个单一的清单文件,所有4应用程序(它们的区别仅在于应用程序资源和一些设置,都将放入资产文件夹)。
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?
在此先感谢意见...
Thanks in advice...
推荐答案
我用:
<permission android:name="${applicationId}.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" />
在Android清单 - 这似乎是正确解析
in the Android manifest - this appears to be resolved correctly.
这篇关于重写GCM许可包preFIX与摇篮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!