无法实现接收器classnotfoundexception

时间:2012-10-24 13:29:04

标签: android classnotfoundexception receiver

我是Android的编程新手,对于出现的意外错误我感到有些恼火。

我正在尝试创建一个具有两个按钮并从教程开始的小部件。我在路上遇到了一些颠簸,但它确实很不错。现在我正在尝试调整小部件的高度和宽度,并尝试添加更多组件。但我一直收到这个错误:

10-24 09:33:40.941: E/AndroidRuntime(280): FATAL EXCEPTION: main
10-24 09:33:40.941: E/AndroidRuntime(280): java.lang.RuntimeException: Unable to instantiate receiver com.example.world.knowledge.agenda.MainActivity: java.lang.ClassNotFoundException: com.example.world.knowledge.agenda.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.world.knowledge.agenda.widget-1.apk]
10-24 09:33:40.941: E/AndroidRuntime(280):  at android.app.ActivityThread.handleReceiver(ActivityThread.java:2789)
10-24 09:33:40.941: E/AndroidRuntime(280):  at android.app.ActivityThread.access$3200(ActivityThread.java:125)
10-24 09:33:40.941: E/AndroidRuntime(280):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2083)
10-24 09:33:40.941: E/AndroidRuntime(280):  at android.os.Handler.dispatchMessage(Handler.java:99)
10-24 09:33:40.941: E/AndroidRuntime(280):  at android.os.Looper.loop(Looper.java:123)
10-24 09:33:40.941: E/AndroidRuntime(280):  at android.app.ActivityThread.main(ActivityThread.java:4627)
10-24 09:33:40.941: E/AndroidRuntime(280):  at java.lang.reflect.Method.invokeNative(Native Method)
10-24 09:33:40.941: E/AndroidRuntime(280):  at java.lang.reflect.Method.invoke(Method.java:521)
10-24 09:33:40.941: E/AndroidRuntime(280):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
10-24 09:33:40.941: E/AndroidRuntime(280):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
10-24 09:33:40.941: E/AndroidRuntime(280):  at dalvik.system.NativeStart.main(Native Method)
10-24 09:33:40.941: E/AndroidRuntime(280): Caused by: java.lang.ClassNotFoundException: com.example.world.knowledge.agenda.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.world.knowledge.agenda.widget-1.apk]
10-24 09:33:40.941: E/AndroidRuntime(280):  at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
10-24 09:33:40.941: E/AndroidRuntime(280):  at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
10-24 09:33:40.941: E/AndroidRuntime(280):  at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
10-24 09:33:40.941: E/AndroidRuntime(280):  at android.app.ActivityThread.handleReceiver(ActivityThread.java:2780)
10-24 09:33:40.941: E/AndroidRuntime(280):  ... 10 more

似乎我所有努力解决这个问题都是徒劳的。 也许你们其中一个人知道如何解决这个问题。 (请尝试将其写下来'虚拟证明'这对我来说都是新鲜的:))

这是我的机器人清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.world.knowledge.agenda.widget"
      android:versionCode="1"
      android:versionName="1.0">
      <uses-sdk android:minSdkVersion="4"/>
    <application android:icon="@drawable/ic_launcher" 
        android:label="@string/app_name"
        android:debuggable="true">

                <!-- this activity will be called, when we fire our self created ACTION_WIDGET_CONFIGURE -->
        <activity android:name="com.example.world.knowledge.agenda.ClickOneActivity" android:label="@string/app_name">
            <intent-filter>
                <action android:name="com.example.world.knowledge.agenda.MainActivity.ACTION_WIDGET_CONFIGURE"/>
                <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <!-- Broadcast Receiver that will process AppWidget updates -->
        <receiver android:name=".MainActivity" 
            android:label="@string/app_name" 
            android:exported="false">
            <intent-filter>
                <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
            </intent-filter>
            <intent-filter>
                <!-- Broadcast Receiver that will also process our self created action -->
                <action android:name="com.example.world.knowledge.agenda.MainActivity.ACTION_WIDGET_RECEIVER"/>
            </intent-filter>
            <meta-data android:name="android.appwidget.provider" android:resource="@xml/button_widget_provider" />
        </receiver>
    </application>
</manifest> 

也许溶剂很简单,但提前谢谢:)

2 个答案:

答案 0 :(得分:0)

不太确定,但您可以尝试更改部件     package="com.example.world.knowledge.agenda.widget" 至     package="com.example.world.knowledge.agenda" 在清单文件声明中。

答案 1 :(得分:0)

显然我的模拟器本身已经损坏,所有这些时间都在搜索一个不是错误的错误...无论如何,我重新安装它并且现在工作正常。