0

I have a problem during runtime of my Android widget with Android 2.3.3 and older.

When i install my widget on the screen, this error is printed :

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)

The problem is due to the fact that the compilator don't arrive to perform the link to the StackWidgetService class at this line in onUpdate method of StackWidgetProvider class :

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]);

The widget works well with other version of Android like 3.0, 4.0 etc...

Please help me :)

pxrb66
  • 119
  • 1
  • 1
  • 9

1 Answers1

0

If you have update your eclipse plugin to ADT 17 maybe your solution is here: Android java.lang.NoClassDefFoundError

Take a look also here: http://android.foxykeep.com/dev/how-to-fix-the-classdefnotfounderror-with-adt-17

Community
  • 1
  • 1
GVillani82
  • 17,196
  • 30
  • 105
  • 172
  • Thanks for your reply. It doesn't seems to be this error. In fact, the problem is about the method : `appWidgetManager.notifyAppWidgetViewDataChanged(i, R.id.stack_view);` This method is not available for min target sdk 10 as specified in my manifest : `` Because i would like to cover Android 2.3.3 (target 10) whereas before i was with min target = 11. How can i do in order to replace this method (notifyAppWidgetViewDataChanged or introduce a condition to use this code only with target = 11 ? – pxrb66 Nov 03 '12 at 14:47