這是我對packageNameSuffix的GCM問題的解決方案。
主要問題是應具有「.debug」後綴的權限名稱。我把這個權限調試並釋放合併到最終清單中的清單。
AndroidManfest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.experiment.myapplication"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.VIBRATE" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
調試AndroidManifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.experiment.myapplication">
<permission android:name="com.experiment.myapplication.debug.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.experiment.myapplication.debug.permission.C2D_MESSAGE" />
<application>
<receiver
android:name=".GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.experiment.myapplication.debug" />
</intent-filter>
</receiver>
</application>
</manifest
>
版本的Android清單
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.experiment.myapplication" >
<permission android:name="com.experiment.myapplication.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.experiment.myapplication.permission.C2D_MESSAGE" />
<application>
<receiver
android:name=".GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.experiment.myapplication" />
</intent-filter>
</receiver>
</application>
</manifest>
當使用新的播放服務而不是舊的gcm-client時,您不需要包特定的權限。 – deekay
我試圖將這種解決方案與Urban Airship一起使用,但並未按預期工作。我仍然收到包名稱上的合併衝突。 –
這對我很好,謝謝! – rharter