在GCM注册中,我的应用程序崩溃了

loading...


0

我的清单许可是在代码之下

<permission
        android:name="com.xyz.xyz.permission.C2D_MESSAGE"
        android:protectionLevel="signature"/>
    <uses-permission 

android:name="com.google.android.c2dm.permission.RECEIVE"/>

这是崩溃

由java.lang.SecurityException引起:未经com.google.android许可,不允许启动服务Intent {act = com.google.android.c2dm.intent.REGISTER pkg = com.google.android.gms(has extras)} . 位于android.app.ContextImpl.startService(ContextImpl.java:1771)的android.app.ContextImp.startService(ContextImpl.java:1771)的android.app.ContextIrap.startService(ContextImpl.java:1721)中的c2dm.permission.RECEIVE(ContextWmplper.java:521) com.google.android.gms.iid.zzc.zz上的com.google.android.gms.iid.zzc.zzb(未知来源)com.google.android.gms.iid.zzc.zz (com.google.android.gms.iid.zzc.zza上的(未知来源)com.google.android.gms.iid.InstanceID.zzc(未知来源)位于com.google.android.gms.iid的com.google.android.gms.iid.zzc.zza(未知来源) android.os.AsyncTask $ . SerialExecutor $ 1的java.util.concurrent.FutureTask.run(FutureTask.java:237)上的android.os.AsyncTask $ 2.call(AsyncTask.java:292)中的.InstanceID.getToken(未知来源)$ SerialExecutor $ 1 java.util.concurrent.ThreadPoolExecutor.runWorker中的.run(AsyncTask.java:231) (ThreadPoolExecutor.java:1112)java.lang.Thread.run上的java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:587)(Thread.java:818)

2回答

  • 0

    你跟着官方tutorial?除了你的接收器(从你的引用部分不清楚)你'd need to grant permissions to SDK' s接收器,即

    <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" />
                <category android:name="<your-package-name>" />
            </intent-filter>
        </receiver>
    

  • 0

    在AndroidManifest.xml中试试这个

    <uses-permission android:name="android.permission.INTERNET" />
        <!-- Required to wakeup the device and deliver messages -->
        <uses-permission android:name="android.permission.WAKE_LOCK" />
        <permission android:name="your_package.permission.C2D_MESSAGE"
            android:protectionLevel="signature"/>
        <uses-permission android:name="your_package.permission.C2D_MESSAGE"/>
    

loading...

评论

暂时没有评论!