java.lang.ClassNotFoundException:没找到类

时间:2014-10-03 19:08:42

标签: android class classnotfoundexception

我的接收器出现了这个问题...

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

已经清理了我的项目并重建了路径......我认为问题出现在这部分" /data/app/com.rafael.acordenoponto-2.apk" ;,但我不会# 39;我知道如何解决...我认为问题就在那里,因为我的apk没有那个" -2"到底......谁知道怎么解决?

这是清单:

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

2 个答案:

答案 0 :(得分:2)

解决!

问题发生的原因是.MonitoraGPS在一个不同的包中...... 所以我只是在清单中的.MonitoraGPS之前添加了包名称并且它有效!

答案 1 :(得分:0)

不是这样的。

  1. 确保您的包名在任何地方都是正确的(java文件,xml文件,AndroidManifest文件......)。
  2. 右键点击该项目;转到构建路径 - &gt; 配置构建路径 - &gt; Java构建路径 - &gt; 订单和导出。然后取消选中 Android依赖关系并检查所有第三方.jar (如果有的话)。