static Organizer org = new Organizer();
static {
// Add 3 sample items.
addItem(new DummyItem("1", org.GetArticles().get(0)[0]));
addItem(new DummyItem("2", "Item 2"));
addItem(new DummyItem("3", "Item 3"));
addItem(new DummyItem("4", "Item 4"));
}
在 Organizer.java 中
public class Organizer {
XMLGettersSetters data;
ArrayList<String[]> articles = new ArrayList<String[]>();
public ArrayList<String[]> GetArticles(){
new getTask().execute("http://www.ynet.co.il/Iphone/0,13257,MainCategory-V7-2,00.xml");
return articles;
}
private class getTask extends AsyncTask<String, Integer, ArrayList<String[]>> {
//AsyncTask
}
}
它返回一个 ExceptionInInitializerError 异常。它是什么?据我了解,这可能与静态 dummyContent 有关。
当我调试时,可以选择逐步执行此操作,如果我进入新的 getTask().execute() 一切正常。但只有当我踏入。否则有这个例外。
编辑:添加了 logcat。
10-05 16:49:37.099: D/dalvikvm(1959): Late-enabling CheckJNI
10-05 16:49:37.189: W/ActivityThread(1959): Application com.example.newsnow is waiting for the debugger on port 8100...
10-05 16:49:37.199: I/System.out(1959): Sending WAIT chunk
10-05 16:49:37.739: I/dalvikvm(1959): Debugger is active
10-05 16:49:37.799: I/System.out(1959): Debugger has connected
10-05 16:49:37.799: I/System.out(1959): waiting for debugger to settle...
10-05 16:49:37.999: I/System.out(1959): waiting for debugger to settle...
10-05 16:49:38.199: I/System.out(1959): waiting for debugger to settle...
10-05 16:49:38.399: I/System.out(1959): waiting for debugger to settle...
10-05 16:49:38.599: I/System.out(1959): waiting for debugger to settle...
10-05 16:49:38.799: I/System.out(1959): waiting for debugger to settle...
10-05 16:49:38.999: I/System.out(1959): waiting for debugger to settle...
10-05 16:49:39.199: I/System.out(1959): waiting for debugger to settle...
10-05 16:49:39.399: I/System.out(1959): waiting for debugger to settle...
10-05 16:49:39.599: I/System.out(1959): waiting for debugger to settle...
10-05 16:49:39.799: I/System.out(1959): waiting for debugger to settle...
10-05 16:49:39.999: I/System.out(1959): waiting for debugger to settle...
10-05 16:49:40.199: I/System.out(1959): debugger has settled (1491)
10-05 16:49:44.959: W/dalvikvm(1959): Exception Ljava/lang/NullPointerException; thrown while initializing Lcom/example/newsnow/dummy/DummyContent;
10-05 16:49:48.099: D/AndroidRuntime(1959): Shutting down VM
10-05 16:49:48.099: W/dalvikvm(1959): threadid=1: thread exiting with uncaught exception (group=0x41a8d930)
10-05 16:49:48.139: E/AndroidRuntime(1959): FATAL EXCEPTION: main
10-05 16:49:48.139: E/AndroidRuntime(1959): java.lang.ExceptionInInitializerError
10-05 16:49:48.139: E/AndroidRuntime(1959): at com.example.newsnow.ItemListFragment.onCreate(ItemListFragment.java:89)
10-05 16:49:48.139: E/AndroidRuntime(1959): at android.support.v4.app.Fragment.performCreate(Fragment.java:1455)
10-05 16:49:48.139: E/AndroidRuntime(1959): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:893)
10-05 16:49:48.139: E/AndroidRuntime(1959): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1082)
10-05 16:49:48.139: E/AndroidRuntime(1959): at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1184)
10-05 16:49:48.139: E/AndroidRuntime(1959): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:285)
10-05 16:49:48.139: E/AndroidRuntime(1959): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
10-05 16:49:48.139: E/AndroidRuntime(1959): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
10-05 16:49:48.139: E/AndroidRuntime(1959): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
10-05 16:49:48.139: E/AndroidRuntime(1959): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
10-05 16:49:48.139: E/AndroidRuntime(1959): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
10-05 16:49:48.139: E/AndroidRuntime(1959): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
10-05 16:49:48.139: E/AndroidRuntime(1959): at android.app.Activity.setContentView(Activity.java:1881)
10-05 16:49:48.139: E/AndroidRuntime(1959): at com.example.newsnow.ItemListActivity.onCreate(ItemListActivity.java:59)
10-05 16:49:48.139: E/AndroidRuntime(1959): at android.app.Activity.performCreate(Activity.java:5104)
10-05 16:49:48.139: E/AndroidRuntime(1959): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
10-05 16:49:48.139: E/AndroidRuntime(1959): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
10-05 16:49:48.139: E/AndroidRuntime(1959): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
10-05 16:49:48.139: E/AndroidRuntime(1959): at android.app.ActivityThread.access$600(ActivityThread.java:141)
10-05 16:49:48.139: E/AndroidRuntime(1959): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
10-05 16:49:48.139: E/AndroidRuntime(1959): at android.os.Handler.dispatchMessage(Handler.java:99)
10-05 16:49:48.139: E/AndroidRuntime(1959): at android.os.Looper.loop(Looper.java:137)
10-05 16:49:48.139: E/AndroidRuntime(1959): at android.app.ActivityThread.main(ActivityThread.java:5041)
10-05 16:49:48.139: E/AndroidRuntime(1959): at java.lang.reflect.Method.invokeNative(Native Method)
10-05 16:49:48.139: E/AndroidRuntime(1959): at java.lang.reflect.Method.invoke(Method.java:511)
10-05 16:49:48.139: E/AndroidRuntime(1959): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
10-05 16:49:48.139: E/AndroidRuntime(1959): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
10-05 16:49:48.139: E/AndroidRuntime(1959): at dalvik.system.NativeStart.main(Native Method)
10-05 16:49:48.139: E/AndroidRuntime(1959): Caused by: java.lang.NullPointerException
10-05 16:49:48.139: E/AndroidRuntime(1959): at com.example.newsnow.dummy.DummyContent.<clinit>(DummyContent.java:32)
10-05 16:49:48.139: E/AndroidRuntime(1959): ... 28 more