2014-09-22 19 views
-1

我知道這個問題已被問到,但這些答案是沒有幫助的。java.lang.IllegalStateException:沒有收件人的行動com.google.android.c2dm.intent.REGISTRATION

我在三星標籤3等特定設備上出現錯誤,並且它在三星Galaxy S3手機上運行良好。

我想在支持谷歌播放服務的所有設備上運行我的應用程序。還有其他的應用程序,其中包括GCM和三星標籤3

我的manifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
package="com.google.android.gcm.demo.app" 
android:versionCode="1" 
android:versionName="1.0" > 

<!-- GCM requires Android SDK version 2.2 (API level 8) or above. --> 
<!-- 
    The targetSdkVersion is optional, but it's always a good practice 
    to target higher versions. 
--> 
<uses-sdk 
    android:minSdkVersion="8" 
    android:targetSdkVersion="16" /> 

<!-- GCM connects to Google Services. --> 
<uses-permission android:name="android.permission.INTERNET" /> 

<!-- GCM requires a Google account. --> 
<uses-permission android:name="android.permission.GET_ACCOUNTS" /> 

<!-- Keeps the processor from sleeping when a message is received. --> 
<uses-permission android:name="android.permission.WAKE_LOCK" /> 

<!-- 
Creates a custom permission so only this app can receive its messages. 

NOTE: the permission *must* be called PACKAGE.permission.C2D_MESSAGE, 
     where PACKAGE is the application's package name. 
--> 
<permission 
    android:name="com.google.android.gcm.demo.app.permission.C2D_MESSAGE" 
    android:protectionLevel="signature" /> 

<uses-permission android:name="com.google.android.gcm.demo.app.permission.C2D_MESSAGE" /> 

<!-- This app has permission to register and receive data message. --> 
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> 

<!-- Main activity. --> 
<application 
    android:icon="@drawable/ic_launcher" 
    android:label="@string/app_name" > 
    <meta-data 
     android:name="com.google.android.gms.version" 
     android:value="@integer/google_play_services_version" /> 

    <activity 
     android:name=".DemoActivity" 
     android:configChanges="orientation|keyboardHidden" 
     android:label="@string/app_name" > 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 

    <!-- 
     BroadcastReceiver that will receive intents from GCM 
     services and handle them to the custom IntentService. 

     The com.google.android.c2dm.permission.SEND permission is necessary 
     so only GCM services can send data messages for the app. 
    --> 
    <receiver 
     android:name="com.google.android.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.google.android.gcm.demo.app" /> 
     </intent-filter> 
    </receiver> 

    <service android:name="com.google.android.gcm.demo.app.GCMIntentService" /> 
</application> 

我的錯誤日誌上運行良好: -

09-22 13:03:06.625: E/AndroidRuntime(22439): FATAL EXCEPTION: main 
09-22 13:03:06.625: E/AndroidRuntime(22439): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.google.android.gcm.demo.app/com.google.android.gcm.demo.app.DemoActivity}: java.lang.IllegalStateException: No receivers for action com.google.android.c2dm.intent.REGISTRATION 
09-22 13:03:06.625: E/AndroidRuntime(22439): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2129) 
09-22 13:03:06.625: E/AndroidRuntime(22439): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2154) 
09-22 13:03:06.625: E/AndroidRuntime(22439): at android.app.ActivityThread.access$700(ActivityThread.java:146) 
09-22 13:03:06.625: E/AndroidRuntime(22439): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1260) 
09-22 13:03:06.625: E/AndroidRuntime(22439): at android.os.Handler.dispatchMessage(Handler.java:99) 
09-22 13:03:06.625: E/AndroidRuntime(22439): at android.os.Looper.loop(Looper.java:137) 
09-22 13:03:06.625: E/AndroidRuntime(22439): at android.app.ActivityThread.main(ActivityThread.java:4949) 
09-22 13:03:06.625: E/AndroidRuntime(22439): at java.lang.reflect.Method.invokeNative(Native Method) 
09-22 13:03:06.625: E/AndroidRuntime(22439): at java.lang.reflect.Method.invoke(Method.java:511) 
09-22 13:03:06.625: E/AndroidRuntime(22439): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1043) 
09-22 13:03:06.625: E/AndroidRuntime(22439): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:810) 
09-22 13:03:06.625: E/AndroidRuntime(22439): at dalvik.system.NativeStart.main(Native Method) 
09-22 13:03:06.625: E/AndroidRuntime(22439): Caused by: java.lang.IllegalStateException: No receivers for action com.google.android.c2dm.intent.REGISTRATION 
09-22 13:03:06.625: E/AndroidRuntime(22439): at com.google.android.gcm.GCMRegistrar.checkReceiver(GCMRegistrar.java:184) 
09-22 13:03:06.625: E/AndroidRuntime(22439): at com.google.android.gcm.GCMRegistrar.checkManifest(GCMRegistrar.java:169) 
09-22 13:03:06.625: E/AndroidRuntime(22439): at com.google.android.gcm.demo.app.DemoActivity.onCreate(DemoActivity.java:54) 
09-22 13:03:06.625: E/AndroidRuntime(22439): at android.app.Activity.performCreate(Activity.java:5185) 
09-22 13:03:06.625: E/AndroidRuntime(22439): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094) 
09-22 13:03:06.625: E/AndroidRuntime(22439): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2093) 
09-22 13:03:06.625: E/AndroidRuntime(22439): ... 11 more 
+0

這是在同一個包。我還說過,該應用程序正在其他設備上運行。如果問題是關於錯誤的軟件包名稱而不是如何在其他設備上運行。 – 2014-09-22 07:58:25

+0

當我的設備在安全模式下運行時,我也遇到了同樣的問題! - 此信息可能對您有所幫助。 – 2015-06-19 07:26:04

+1

對我的問題進行低估的人請告訴我我的問題以何種方式不適當的原因?你甚至讀過我的問題嗎? – 2015-06-30 09:12:39

回答

0

你沒有實現了接收器來接收GCM回調。

<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="smart.emergencyservice" /> 
     </intent-filter> 
    </receiver> 

    <service android:name="smart.emergencyservice.GCMIntentService" /> 

,然後進行GCMIntentService延伸GCMBaseIntentService

+0

我已經實現了它,並且在某些平板電腦上運行良好。它不適用於某些特定的平板電腦。 – 2015-01-12 09:42:55

+1

如果你的平板電腦運行的是android 4.0.3或者運行在4.0.4或更高版本上的設備運行不正常,那麼你需要一個與平板電腦相關聯的gmail帳戶才能正常工作。 – 2015-01-16 05:37:45

+0

我在我的平板電腦中關聯了gmail帳戶。我在Samsung galaxy tab 3中得到這個問題,而不是在nexus 7上,都有gmail賬號和4.0.4以上的操作系統 – 2015-06-30 09:15:58

相關問題