gpt4 book ai didi

java - 空指针异常 : An error occurred while executing doInBackground() :application crash

转载 作者:行者123 更新时间:2023-11-30 02:22:36 24 4
gpt4 key购买 nike

我收到以下运行时异常。

Fatal signal 6 (SIGABRT) at 0x00000820 (code=-6), thread 2080
thread eixiting with uncaught exception
java.lang.RuntimeException: An error occured while executing doInBackground()

我在下面发布了完整的堆栈跟踪错误:

堆栈跟踪:

02-02 02:13:17.137: E/dalvikvm(2080): VM aborting
02-02 02:13:17.137: A/libc(2080): Fatal signal 6 (SIGABRT) at 0x00000820 (code=-6), thread 2080 (e.quranmadeeasy)
02-02 02:13:20.177: D/dalvikvm(2140): GC_FOR_ALLOC freed 101K, 8% free 2981K/3208K, paused 74ms, total 75ms
02-02 02:13:20.177: I/dalvikvm-heap(2140): Grow heap (frag case) to 3.637MB for 635812-byte allocation
02-02 02:13:20.217: D/dalvikvm(2140): GC_FOR_ALLOC freed 0K, 6% free 3602K/3832K, paused 36ms, total 36ms
02-02 02:13:20.397: W/dalvikvm(2140): threadid=13: thread exiting with uncaught exception (group=0xb3a3cba8)
02-02 02:13:20.397: E/AndroidRuntime(2140): FATAL EXCEPTION: AsyncTask #1
02-02 02:13:20.397: E/AndroidRuntime(2140): Process: com.qrme.quranmadeeasy, PID: 2140
02-02 02:13:20.397: E/AndroidRuntime(2140): java.lang.RuntimeException: An error occured while executing doInBackground()
02-02 02:13:20.397: E/AndroidRuntime(2140): at android.os.AsyncTask$3.done(AsyncTask.java:300)
02-02 02:13:20.397: E/AndroidRuntime(2140): at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
02-02 02:13:20.397: E/AndroidRuntime(2140): at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
02-02 02:13:20.397: E/AndroidRuntime(2140): at java.util.concurrent.FutureTask.run(FutureTask.java:242)
02-02 02:13:20.397: E/AndroidRuntime(2140): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
02-02 02:13:20.397: E/AndroidRuntime(2140): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
02-02 02:13:20.397: E/AndroidRuntime(2140): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
02-02 02:13:20.397: E/AndroidRuntime(2140): at java.lang.Thread.run(Thread.java:841)
02-02 02:13:20.397: E/AndroidRuntime(2140): Caused by: java.lang.NullPointerException
02-02 02:13:20.397: E/AndroidRuntime(2140): at com.qrme.quranmadeeasy.LessonActivity$getLesson.doInBackground(LessonActivity.java:259)
02-02 02:13:20.397: E/AndroidRuntime(2140): at com.qrme.quranmadeeasy.LessonActivity$getLesson.doInBackground(LessonActivity.java:1)
02-02 02:13:20.397: E/AndroidRuntime(2140): at android.os.AsyncTask$2.call(AsyncTask.java:288)
02-02 02:13:20.397: E/AndroidRuntime(2140): at java.util.concurrent.FutureTask.run(FutureTask.java:237)
02-02 02:13:20.397: E/AndroidRuntime(2140): ... 4 more

我在下面的代码中指出了错误行。

类(class) Activity .java:

public class LessonActivity extends Activity implements OnItemClickListener {

AdapterLesson al; // creating object of AdapterLesson class
static ArrayList<Lesson> lessonList = null;
static ArrayList<Settings> settings = null;
int chapterId;
AdapterPages adapPage;
static ArrayList<Page> selectedpageList = null;
static ArrayList<Page> pageList = null;

@Override
protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
setContentView(R.layout.activity_lesson);
ParseAnalytics.trackAppOpened(getIntent());
if (getIntent() != null && getIntent().getExtras() != null) {
String chapt_id = getIntent().getExtras().getString("CHAPTER_ID");
chapter = getIntent().getExtras().getString("CHAPTER_NAME");
// txtChapterdetails.setText(chapter);
if (chapt_id != null && !chapt_id.equalsIgnoreCase("")) {
chapterId = Integer.parseInt(chapt_id);
}
}
initialize();
listLesson.setOnItemClickListener(this);
}


public class getLesson extends AsyncTask<String, Void, String> {


@Override
protected String doInBackground(String... params) {


lessonList = DatabaseQueryHelper.getInstance().getLesson(chapterId); --->259th line

return null;
}

@Override
protected void onPreExecute() {
super.onPreExecute();

}

@Override
protected void onPostExecute(String result) {

if(lessonList!=null)
{
if(lessonList.size()>0)
{
al = new AdapterLesson(LessonActivity.this, lessonList);
listLesson.setAdapter(al);
}
}
}
}
}

任何人都可以帮助我。谢谢。

最佳答案

问题出在 DatabaseQueryHelper 类中。在实例初始化之前调用方法 getInstance()。所以当你调用它时你会得到 NullPointerException。寻找ways to implement a Singleton为了纠正这个。

关于java - 空指针异常 : An error occurred while executing doInBackground() :application crash,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28273530/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com