类路径DexPathList上找不到异常GCMIntentServices

时间:2014-07-07 04:50:54

标签: android google-cloud-messaging

我检查了GcmIntentServices上的大部分可用资料,但无法弄清楚我面临的问题..

推送通知代码在登录页面上提供,下一页是homeScreen,但意图确实发生..但在主页上一段时间后...应用程序崩溃..

我的日志cat提供了以下错误..

 E/AndroidRuntime(1449): FATAL EXCEPTION: main
 E/AndroidRuntime(1449): Process: com.example.smss, PID: 1449
 E/AndroidRuntime(1449): java.lang.RuntimeException: Unable to instantiate service
  com.example.smss.GCMIntentService: java.lang.ClassNotFoundException: 
 Didn't find class "com.example.smss.GCMIntentService" on path:
  DexPathList[[zip file "/data/app/com.example.smss-1.apk"],
 nativeLibraryDirectories=[/data/app-lib/com.example.smss-2, /vendor/lib, /system/lib]]

 E/AndroidRuntime(1449):    at android.app.ActivityThread.handleCreateService(ActivityThread.java:2556)
 E/AndroidRuntime(1449):    at android.app.ActivityThread.access$1800(ActivityThread.java:135)
 E/AndroidRuntime(1449):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
 E/AndroidRuntime(1449):    at android.os.Handler.dispatchMessage(Handler.java:102)
 E/AndroidRuntime(1449):    at android.os.Looper.loop(Looper.java:136)
 E/AndroidRuntime(1449):    at android.app.ActivityThread.main(ActivityThread.java:5017)
 E/AndroidRuntime(1449):    at java.lang.reflect.Method.invokeNative(Native Method)
 E/AndroidRuntime(1449):    at java.lang.reflect.Method.invoke(Method.java:515)
 E/AndroidRuntime(1449):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
 E/AndroidRuntime(1449):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
 E/AndroidRuntime(1449):    at dalvik.system.NativeStart.main(Native Method)
 E/AndroidRuntime(1449): Caused by: java.lang.ClassNotFoundException:
  Didn't find class "com.example.smss.GCMIntentService" on path:
  DexPathList[[zip file "/data/app/com.example.smss-1.apk"],
 nativeLibraryDirectories=[/data/app-lib/com.example.smss-2, /vendor/lib, /system/lib]]

 E/AndroidRuntime(1449):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
 E/AndroidRuntime(1449):    at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
 E/AndroidRuntime(1449):    at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
 E/AndroidRuntime(1449):    at android.app.ActivityThread.handleCreateService(ActivityThread.java:2553)
 E/AndroidRuntime(1449):    ... 10 more

为什么会发生这种情况?

这是我的表现..

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.smss"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="18" />
<!-- GCM connects to Internet 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. -->
<permission
    android:name="com.example.smss.permission.C2D_MESSAGE"
    android:protectionLevel="signature" />

<uses-permission android:name="com.example.smss.permission.C2D_MESSAGE" />

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

<!-- Network State Permissions to detect Internet status -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<!-- Permission to vibrate -->
<uses-permission android:name="android.permission.VIBRATE" />

<application
    android:allowBackup="true"
    android:icon="@drawable/logo"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.example.smss.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>
    <!-- Register Activity -->
    <activity
        android:name="com.quinoid.sms.pushnotifications.RegisterActivity"
        android:label="@string/app_name" >
    </activity>

    <!-- Main Activity -->
    <activity
        android:name="com.quinoid.sms.pushnotifications.InitialActivity"
        android:configChanges="orientation|keyboardHidden"
        android:label="@string/app_name" >
    </activity>
    <activity android:name="com.example.smss.homepage"></activity>



     <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.androidhive.pushnotifications" />
        </intent-filter>
    </receiver>

    <service android:name=".GCMIntentService" />
</application>

2 个答案:

答案 0 :(得分:1)

好的,您需要在Manifest使用中修复PackageName:

<service android:name="com.quinoid.sms.pushnotifications.GCMIntentService" />

答案 1 :(得分:1)

您有两个包。因此,在注册GCM服务时,请指定package.GCMIntentService