I'm new to programming for android and am a bit annoyed by an unexpected error that comes up.

I'm trying to make a widget that has two buttons and started from a tutorial. I had a few bumps in the road but it managed out pretty decent. Now I'm trying to adjust the widget height and width and try to add some more components. But I keep getting this error:

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

And it seems that all my efforts to fix this have gone in vain. Perhaps one of you guys know how I can fix this. (please try to write it down 'dummy proof' this is all very new to me :) )

This is my android manifest:

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

Perhaps the sollution is very simple, but thanks in advance :)

有帮助吗?

解决方案 2

Apparently my emulator itself was corrupted, all these time searching for an error that was'n t one... Anyway, I reïnstalled it and it works fine now.

其他提示

Not very sure, but you could try altering the part package="com.example.world.knowledge.agenda.widget" to package="com.example.world.knowledge.agenda" in the manifest file declaration.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top