2012-11-03 103 views
0

我在使用Android 2.3.3和更舊版本的Android小部件運行時遇到問題。運行時java.lang.NoClassDefFoundError運行時Android Widget

當我在屏幕上安裝我的窗口小部件,印製這樣的錯誤:

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沒有到達這條線進行鏈接StackWidgetService類在StackWidgetProvider類的onUpdate方法:

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

小部件與像3.0,4.0等的Android的其他版本的效果很好...

請幫助我:)

+0

您已聲明清單中的服務? – GVillani82

+0

即使我有同樣的問題。你解決了這個問題嗎?請幫我解決這個問題 – chaitu2408

回答

0

如果你有更新的Eclipse插件ADT 17,也許您的解決方案是在這裏:Android java.lang.NoClassDefFoundError

看看這裏也:http://android.foxykeep.com/dev/how-to-fix-the-classdefnotfounderror-with-adt-17

+0

感謝您的回覆。它似乎不是這個錯誤。實際上,這個問題是關於這個方法的:\t \t'appWidgetManager.notifyAppWidgetViewDataChanged(i,R.id.stack_view);'這個方法不適用於我的manifest中指定的min target sdk 10:''因爲我想覆蓋Android 2.3.3(目標10),而之前我與最小目標= 11。我該怎麼做才能取代這種方法notifyAppWidgetViewDataChanged還是引入一個條件以僅在target = 11時使用此代碼? – pxrb66

相關問題