Gor*_*ets 10 java android gradle google-cloud-messaging android-productflavors
我有GCM示例android gradle项目.它运行良好,当我添加2种口味时,推送通知停止工作.我的编译清单(取自app\build\intermediates\manifests\ex\debug)文件如下:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.flavor.app"
<uses-permission android:name="com.flavor.app.permission.C2D_MESSAGE" />
<permission
android:name="com.flavor.app.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<receiver
android:name="com.google.android.gcm.GCMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.flavor.app" />
</intent-filter>
</receiver>
<service android:name="com.ex.app.GCMIntentService" />
<service
android:name="com.ex.app.AppLocationService"
class=".AppLocationService" >
<intent-filter>
<action
android:name=".AppLocationService"
android:value=".AppLocationService" />
</intent-filter>
</service>
Run Code Online (Sandbox Code Playgroud)
我该怎么做才能解决这个问题?请帮忙.
UPD1.我正在使用gradle v.0.12 +.我认为我的最终清单文件看起来不错,GCMRegistrar.checkManifest(this); - 没有错误,但GCMRegistrar.isRegistered(this)总是假的.=(
UPD2.我的第一个带有原始包名称的flavor项目(作为main分支中的项目)运行良好,但是更改包的第二个风格不起作用(pushId仍然是空的),但是在清单文件中,所有的permitions都是正确的.
Mar*_*tek 37
Simpy使用这样的${applicationId}别名
<permission android:name= "${applicationId}.permission.C2D_MESSAGE"
android:protectionLevel= "signature" />
<uses-permission android:name= "${applicationId}.permission.C2D_MESSAGE" />
<uses-permission android:name= "com.google.android.c2dm.permission.RECEIVE" />
Run Code Online (Sandbox Code Playgroud)
而对于相应的接收器使用此
<receiver
android:name = "com.mixpanel.android.mpmetrics.GCMReceiver"
android:permission = "com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name = "com.google.android.c2dm.intent.RECEIVE"/>
<action android:name = "com.google.android.c2dm.intent.REGISTRATION"/>
<category android:name = "${applicationId}"/>
</intent-filter>
</receiver>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3284 次 |
| 最近记录: |