运行时Android Widget中的java.lang.NoClassDefFoundError

时间:2012-11-03 10:57:14

标签: android android-intent android-widget appwidgetprovider

我在运行Android 2.3.3及更早版本的Android小部件时出现问题。

当我在屏幕上安装我的小部件时,会打印出此错误:

11-03 10:26:31.127: E/AndroidRuntime(404): FATAL EXCEPTION: main
11-03 10:26:31.127: E/AndroidRuntime(404): java.lang.NoClassDefFoundError: com.app.myapp.StackWidgetService
11-03 10:26:31.127: E/AndroidRuntime(404):  at com.app.myapp.StackWidgetProvider.onUpdate(StackWidgetProvider.java:229)
11-03 10:26:31.127: E/AndroidRuntime(404):  at android.appwidget.AppWidgetProvider.onReceive(AppWidgetProvider.java:61)
11-03 10:26:31.127: E/AndroidRuntime(404):  at com.app.mobideals.StackWidgetProvider.onReceive(StackWidgetProvider.java:216)
11-03 10:26:31.127: E/AndroidRuntime(404):  at android.app.ActivityThread.handleReceiver(ActivityThread.java:1794)
11-03 10:26:31.127: E/AndroidRuntime(404):  at android.app.ActivityThread.access$2400(ActivityThread.java:117)
11-03 10:26:31.127: E/AndroidRuntime(404):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:981)
11-03 10:26:31.127: E/AndroidRuntime(404):  at android.os.Handler.dispatchMessage(Handler.java:99)
11-03 10:26:31.127: E/AndroidRuntime(404):  at android.os.Looper.loop(Looper.java:123)
11-03 10:26:31.127: E/AndroidRuntime(404):  at android.app.ActivityThread.main(ActivityThread.java:3683)
11-03 10:26:31.127: E/AndroidRuntime(404):  at java.lang.reflect.Method.invokeNative(Native Method)
11-03 10:26:31.127: E/AndroidRuntime(404):  at java.lang.reflect.Method.invoke(Method.java:507)
11-03 10:26:31.127: E/AndroidRuntime(404):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
11-03 10:26:31.127: E/AndroidRuntime(404):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
11-03 10:26:31.127: E/AndroidRuntime(404):  at dalvik.system.NativeStart.main(Native Method)

问题是由于compilator没有到达,在StackWidgetProvider类的onUpdate方法中执行此行的StackWidgetService类的链接:

public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {

        // update each of the widgets with the remote adapter
        for (int i = 0; i < appWidgetIds.length; ++i) {

            // Here we setup the intent which points to the StackViewService which will
            // provide the views for this collection.
            Intent intent = new Intent(context, StackWidgetService.class);
            intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);

该小部件适用于其他版本的Android,如3.0,4.0等......

请帮帮我:)。

1 个答案:

答案 0 :(得分:0)

如果你已经将你的eclipse插件更新到ADT 17,那么你的解决方案就在这里:Android java.lang.NoClassDefFoundError

请看这里:http://android.foxykeep.com/dev/how-to-fix-the-classdefnotfounderror-with-adt-17