class not found exception GCMIntentServices on path DexPathList

独自空忆成欢 提交于 2019-12-23 06:04:03

问题


i have checked most of the available material on GcmIntentServices but couldn't figure out the problem i am facing..

The Push notification code is provided on the login page and the next page is homeScreen, but the intent occurs without fail.. yet after some time on the home page.. the app crashes..

my log cat provides the following error..

 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

why is this occuring??

this is my manifest..

<?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>


回答1:


ok you need to fix the PackageName in the Manifest use:

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



回答2:


You have two packages.So while registering the GCM service specify the package.GCMIntentService



来源:https://stackoverflow.com/questions/24603236/class-not-found-exception-gcmintentservices-on-path-dexpathlist

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!