【问题标题】:class not found exception GCMIntentServices on path DexPathList在路径 DexPathList 上找不到类异常 GCMIntentServices
【发布时间】:2014-08-27 12:01:51
【问题描述】:

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

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

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

 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>

【问题讨论】:

  • 在这里查看我的答案:stackoverflow.com/a/21898031/1785412
  • 你项目的默认包是什么?
  • 我的主要类在 com.example.smss 包中,而所有 gcm 意图类都是 com.quinoid.sms.pushnotifications @SMR
  • 已经做了以下清理应用程序在首选项上检查“Android私有库”> Java构建路径多次重启Eclipse@SiddharthVyas

标签: android google-cloud-messaging


【解决方案1】:

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

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

【讨论】:

  • 这是什么? @SMR
【解决方案2】:

你有两个包。所以在注册 GCM 服务时指定package.GCMIntentService

【讨论】:

    猜你喜欢
    • 2017-08-13
    • 2016-02-04
    • 2017-09-12
    • 2014-05-29
    • 2018-08-08
    • 2015-07-01
    • 2018-12-30
    • 2015-01-02
    相关资源
    最近更新 更多