我有一个应用程序,我使用GCM接收推送通知。 我收到了一些崩溃跟踪:
Fatal Exception: java.lang.RuntimeException: Unable to start receiver com.google.android.gms.gcm.GcmReceiver: java.lang.SecurityException: Not allowed to start service Intent { act=com.google.android.gms.iid.InstanceID flg=0x10 pkg=com.example.app (has extras) } without permission not exported from uid 10043
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2495)
at android.app.ActivityThread.access$1500(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1374)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:213)
at android.app.ActivityThread.main(ActivityThread.java:5225)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:741)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
at dalvik.system.NativeStart.main(NativeStart.java)
Caused by java.lang.SecurityException: Not allowed to start service Intent { act=com.google.android.gms.iid.InstanceID flg=0x10 pkg=com.example.app (has extras) } without permission not exported from uid 10043
at android.app.ContextImpl.startServiceAsUser(ContextImpl.java:1446)
at android.app.ContextImpl.startService(ContextImpl.java:1428)
at android.content.ContextWrapper.startService(ContextWrapper.java:473)
at android.content.ContextWrapper.startService(ContextWrapper.java:473)
at android.support.v4.a.m.a(WakefulBroadcastReceiver.java:89)
at com.google.android.gms.gcm.GcmReceiver.onReceive(Unknown Source)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2488)
at android.app.ActivityThread.access$1500(ActivityThread.java:150)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1374)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:213)
at android.app.ActivityThread.main(ActivityThread.java:5225)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:741)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
at dalvik.system.NativeStart.main(NativeStart.java)
并非在所有设备上都会发生这种情况。我正在使用谷歌播放服务7.5。这是我的清单文件中的权限和其他gcm相关内容:
<permission android:name="${applicationId}.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" />
和
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
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>
<service
android:name="com.example.app.service.GcmListenerService"
android:exported="false" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
<service
android:name="com.example.app.service.InstanceIdListenerService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID"/>
</intent-filter>
</service>
任何人都可以告诉我这里发生了什么。感谢。