Android 推送通知权限
Android Push Notification Permissions
我在我的应用程序中使用 PushBots 进行通知。我正在使用 Android Studio 作为 IDE。我确定我的 g2d 权限是正确的。当我尝试使用 Android Studio 在虚拟设备上打开我的应用程序时,它运行良好,但当我在真实设备 (lollipop 5.1) 上尝试它时,它 "unfortunately stopped" 并关闭。我真的不知道那有什么问题......谢谢你的建议。
这是我的 logcat 日志:
04-14 01:17:43.769 23197-23197/com.madtriangle.orbitals E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.madtriangle.orbitals, PID: 23197
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.madtriangle.orbitals/com.madtriangle.orbitals.AndroidLauncher}: java.lang.IllegalStateException: Application does not define permission com.madtriangle.orbitals.permission.C2D_MESSAGE
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2658)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2723)
at android.app.ActivityThread.access0(ActivityThread.java:172)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1422)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5832)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
Caused by: java.lang.IllegalStateException: Application does not define permission com.madtriangle.orbitals.permission.C2D_MESSAGE
at com.pushbots.google.gcm.GCMRegistrar.checkManifestFile(GCMRegistrar.java:147)
at com.pushbots.push.Pushbots.check(Pushbots.java:221)
at com.pushbots.push.Pushbots.init(Pushbots.java:102)
at com.madtriangle.orbitals.AndroidLauncher.onCreate(AndroidLauncher.java:70)
at android.app.Activity.performCreate(Activity.java:6221)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2611)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2723)
at android.app.ActivityThread.access0(ActivityThread.java:172)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1422)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5832)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
这是我的清单文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.madtriangle.orbitals"
android:versionCode="6"
android:versionName="1.14">
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="19"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="com.android.vending.BILLING"/>
<!-- GCM requires a Google account. -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<permission android:name="com.madtriangle.orbital.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.madtriangle.orbitals.permission.C2D_MESSAGE" />
<!-- This app has permission to register and receive dataf message. -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/GdxTheme">
<activity
android:name="com.madtriangle.orbitals.AndroidLauncher"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="com.madtriangle.ultrasquares.MESSAGE"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:name="com.pushbots.push.PBListener"/>
<receiver
android:name="com.pushbots.google.gcm.GCMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<!-- Receives the actual messages. -->
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
<!-- Receives the registration id. -->
<action android:name="com.google.android.c2dm.intent.REGISTRATION"/>
<category android:name="com.madtriangle.paddle"/>
</intent-filter>
</receiver>
<receiver android:name="com.pushbots.push.DefaultPushHandler"/>
<service android:name="com.pushbots.push.GCMIntentService"/>
<service
android:name="org.openudid.OpenUDID_service"
android:exported="false">
<intent-filter>
<action android:name="org.openudid.GETUDID"/>
</intent-filter>
</service>
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
<meta-data
android:name="com.google.android.gms.games.APP_ID"
android:value="@string/app_id"/>
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
</application>
</manifest>
好的,我解决了,
应该是(包名中缺少字母 s)
我在我的应用程序中使用 PushBots 进行通知。我正在使用 Android Studio 作为 IDE。我确定我的 g2d 权限是正确的。当我尝试使用 Android Studio 在虚拟设备上打开我的应用程序时,它运行良好,但当我在真实设备 (lollipop 5.1) 上尝试它时,它 "unfortunately stopped" 并关闭。我真的不知道那有什么问题......谢谢你的建议。
这是我的 logcat 日志:
04-14 01:17:43.769 23197-23197/com.madtriangle.orbitals E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.madtriangle.orbitals, PID: 23197
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.madtriangle.orbitals/com.madtriangle.orbitals.AndroidLauncher}: java.lang.IllegalStateException: Application does not define permission com.madtriangle.orbitals.permission.C2D_MESSAGE
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2658)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2723)
at android.app.ActivityThread.access0(ActivityThread.java:172)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1422)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5832)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
Caused by: java.lang.IllegalStateException: Application does not define permission com.madtriangle.orbitals.permission.C2D_MESSAGE
at com.pushbots.google.gcm.GCMRegistrar.checkManifestFile(GCMRegistrar.java:147)
at com.pushbots.push.Pushbots.check(Pushbots.java:221)
at com.pushbots.push.Pushbots.init(Pushbots.java:102)
at com.madtriangle.orbitals.AndroidLauncher.onCreate(AndroidLauncher.java:70)
at android.app.Activity.performCreate(Activity.java:6221)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2611)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2723)
at android.app.ActivityThread.access0(ActivityThread.java:172)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1422)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5832)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
这是我的清单文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.madtriangle.orbitals"
android:versionCode="6"
android:versionName="1.14">
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="19"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="com.android.vending.BILLING"/>
<!-- GCM requires a Google account. -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<permission android:name="com.madtriangle.orbital.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.madtriangle.orbitals.permission.C2D_MESSAGE" />
<!-- This app has permission to register and receive dataf message. -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/GdxTheme">
<activity
android:name="com.madtriangle.orbitals.AndroidLauncher"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="com.madtriangle.ultrasquares.MESSAGE"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:name="com.pushbots.push.PBListener"/>
<receiver
android:name="com.pushbots.google.gcm.GCMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<!-- Receives the actual messages. -->
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
<!-- Receives the registration id. -->
<action android:name="com.google.android.c2dm.intent.REGISTRATION"/>
<category android:name="com.madtriangle.paddle"/>
</intent-filter>
</receiver>
<receiver android:name="com.pushbots.push.DefaultPushHandler"/>
<service android:name="com.pushbots.push.GCMIntentService"/>
<service
android:name="org.openudid.OpenUDID_service"
android:exported="false">
<intent-filter>
<action android:name="org.openudid.GETUDID"/>
</intent-filter>
</service>
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
<meta-data
android:name="com.google.android.gms.games.APP_ID"
android:value="@string/app_id"/>
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
</application>
</manifest>
好的,我解决了,
应该是(包名中缺少字母 s)