java.lang.ClassNotFoundException: Didn't find

2019-02-28 09:13发布

i'm having this problem with my receiver...

10-03 15:38:34.238: E/AndroidRuntime(32219): FATAL EXCEPTION: main
10-03 15:38:34.238: E/AndroidRuntime(32219): java.lang.RuntimeException: Unable to instantiate receiver com.rafael.acordenoponto.MonitoraGPS: java.lang.ClassNotFoundException: Didn't find class "com.rafael.acordenoponto.MonitoraGPS" on path: /data/app/com.rafael.acordenoponto-2.apk
10-03 15:38:34.238: E/AndroidRuntime(32219):    at android.app.ActivityThread.handleReceiver(ActivityThread.java:2285)
10-03 15:38:34.238: E/AndroidRuntime(32219):    at android.app.ActivityThread.access$1600(ActivityThread.java:137)
10-03 15:38:34.238: E/AndroidRuntime(32219):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1322)
10-03 15:38:34.238: E/AndroidRuntime(32219):    at android.os.Handler.dispatchMessage(Handler.java:99)
10-03 15:38:34.238: E/AndroidRuntime(32219):    at android.os.Looper.loop(Looper.java:137)
10-03 15:38:34.238: E/AndroidRuntime(32219):    at android.app.ActivityThread.main(ActivityThread.java:5031)
10-03 15:38:34.238: E/AndroidRuntime(32219):    at java.lang.reflect.Method.invokeNative(Native Method)
10-03 15:38:34.238: E/AndroidRuntime(32219):    at java.lang.reflect.Method.invoke(Method.java:511)
10-03 15:38:34.238: E/AndroidRuntime(32219):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
10-03 15:38:34.238: E/AndroidRuntime(32219):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
10-03 15:38:34.238: E/AndroidRuntime(32219):    at dalvik.system.NativeStart.main(Native Method)
10-03 15:38:34.238: E/AndroidRuntime(32219): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.rafael.acordenoponto.MonitoraGPS" on path: /data/app/com.rafael.acordenoponto-2.apk
10-03 15:38:34.238: E/AndroidRuntime(32219):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
10-03 15:38:34.238: E/AndroidRuntime(32219):    at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
10-03 15:38:34.238: E/AndroidRuntime(32219):    at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
10-03 15:38:34.238: E/AndroidRuntime(32219):    at android.app.ActivityThread.handleReceiver(ActivityThread.java:2280)
10-03 15:38:34.238: E/AndroidRuntime(32219):    ... 10 more

had alread cleaned my project and rebuilt the path... I think that the problem is in this part "/data/app/com.rafael.acordenoponto-2.apk", but i don't know how to solve... i think the problem is there because my apk does not have that "-2" in the end... anyone know how to solve?

Here's the manifest:

<receiver android:name=".MonitoraGPS">
    <intent-filter >
        <action android:name="MONITORAR"/>
        <category android:name="android.intent.category.DEFAULT" />     
    </intent-filter>
</receiver>

2条回答
Summer. ? 凉城
2楼-- · 2019-02-28 09:15

It's no that.

  1. Make sure your package-name is correct in anywhere (the java files, the xml files, AndroidManifest files...).
  2. Right click on the project; goto Build Path --> Configure Build Path --> Java Build Path --> Order and Export. Then uncheck Android Dependencies and check all third-party .jar, if you have any.
查看更多
forever°为你锁心
3楼-- · 2019-02-28 09:19

solved!

the problem happened because .MonitoraGPS was in a different package... so i just added the package name before .MonitoraGPS in the manifest and it worked!

查看更多
登录 后发表回答