在我的常规版本中,gcm可以正常工作,但是当我使用flavor来更改com名称时,就会停止工作。我的IntentService永远不会被初始化。我应该如何设置我的清单文件以便发生这种情况?使用Gradle更改软件包名称时,未注册GCM
- 我已将它们添加到开发者控制台。
- 我使用gradle这个com.android.tools.build:gradle:0.11.+”
我得到的日志
V/GCMBroadcastReceiver﹕ onReceive: com.google.android.c2dm.intent.REGISTRATION
V/GCMBroadcastReceiver﹕ GCM IntentService class: com.sample.app.dev.GCMIntentService
V/GCMBaseIntentService﹕ Acquiring wakelock
,然后什么都没有。我的自定义IntentService类永远不会被初始化,并且我的registrationId保持空白。我目前的实现类似于这里的:https://stackoverflow.com/a/20334397/198034
我应该如何设置我的清单以获得gradle 0.11。+ flavor以使用gcm?
下面是我的一个风格的清单,我在主清单中有更多的代码(所有需要的权限等),但没有其他处理gcm的代码。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sample.app"
android:versionCode="45"
android:versionName="0.6.5" >
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:name="com.sample.app.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.sample.app.permission.C2D_MESSAGE" />
<application
android:allowBackup="true"
android:icon="@drawable/app_icon"
android:label="@string/app_name" >
<service android:name=".GCMIntentService" />
<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="${packageName}" />
</intent-filter>
</receiver>
</application>
</manifest>
请发表您的清单 – Eran
我没有发布它,因为使用我已经尝试了各种不同的配置,我的清单非常大。但我会加上重要的一点。 – QuinnBaetz