我在运行时收到堆栈跟踪错误。
Runtime Exception : An error occurred while executing doInBackground()
Fatal signal 6 (SIGABRT) at 0x0000162c (code=-6), thread 5676
我发布了完整的堆栈跟踪并指出了下面的错误行 编码
加载片段页面时,我收到此日志错误。严重的应用程序崩溃。它已经在所有设备中发生。
堆栈跟踪:
01-30 05:05:57.213: E/dalvikvm(5676): VM aborting
01-30 05:05:57.213: A/libc(5676): Fatal signal 6 (SIGABRT) at 0x0000162c (code=-6), thread 5676 (e.quranmadeeasy)
01-30 05:05:57.761: D/dalvikvm(5767): GC_FOR_ALLOC freed 121K, 6% free 3345K/3524K, paused 2ms, total 2ms
01-30 05:05:57.761: I/dalvikvm-heap(5767): Grow heap (frag case) to 4.394MB for 1127532-byte allocation
01-30 05:05:57.761: D/dalvikvm(5767): GC_FOR_ALLOC freed <1K, 4% free 4446K/4628K, paused 2ms, total 2ms
01-30 05:05:57.805: W/dalvikvm(5767): threadid=12: thread exiting with uncaught exception (group=0xa4cc6b20)
01-30 05:05:57.805: W/dalvikvm(5767): threadid=15: thread exiting with uncaught exception (group=0xa4cc6b20)
01-30 05:05:57.805: I/Process(5767): Sending signal. PID: 5767 SIG: 9
01-30 05:05:57.805: E/AndroidRuntime(5767): FATAL EXCEPTION: AsyncTask #1
01-30 05:05:57.805: E/AndroidRuntime(5767): Process: com.qrme.quranmadeeasy, PID: 5767
01-30 05:05:57.805: E/AndroidRuntime(5767): java.lang.RuntimeException: An error occured while executing doInBackground()
01-30 05:05:57.805: E/AndroidRuntime(5767): at android.os.AsyncTask$3.done(AsyncTask.java:300)
01-30 05:05:57.805: E/AndroidRuntime(5767): at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
01-30 05:05:57.805: E/AndroidRuntime(5767): at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
01-30 05:05:57.805: E/AndroidRuntime(5767): at java.util.concurrent.FutureTask.run(FutureTask.java:242)
01-30 05:05:57.805: E/AndroidRuntime(5767): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
01-30 05:05:57.805: E/AndroidRuntime(5767): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
01-30 05:05:57.805: E/AndroidRuntime(5767): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
01-30 05:05:57.805: E/AndroidRuntime(5767): at java.lang.Thread.run(Thread.java:841)
01-30 05:05:57.805: E/AndroidRuntime(5767): Caused by: java.lang.NullPointerException
01-30 05:05:57.805: E/AndroidRuntime(5767): at com.qrme.quranmadeeasy.LessonActivity$getLesson.doInBackground(LessonActivity.java:258)
01-30 05:05:57.805: E/AndroidRuntime(5767): at com.qrme.quranmadeeasy.LessonActivity$getLesson.doInBackground(LessonActivity.java:1)
01-30 05:05:57.805: E/AndroidRuntime(5767): at android.os.AsyncTask$2.call(AsyncTask.java:288)
01-30 05:05:57.805: E/AndroidRuntime(5767): at java.util.concurrent.FutureTask.run(FutureTask.java:237)
01-30 05:05:57.805: E/AndroidRuntime(5767): ... 4 more
LessonActivity.java:
public class LessonActivity extends Activity implements OnItemClickListener {
static ArrayList<Lesson> lessonList =null ;
static ArrayList<Settings> settings = null;
int chapterId;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
setContentView(R.layout.activity_lesson);
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);
}
@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
new getLesson().execute("");
}
..............
..............
// Async Task for getting all lesson of a chapter
public class getLesson extends AsyncTask<String, Void, String> {
// ProgressDialog pd; // progress dialog declaration
@Override
protected String doInBackground(String... params) {
lessonList = DatabaseQueryHelper.getInstance().getLesson(chapterId); -->258th 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);
}
}
}
}
}
任何人都可以帮助我。谢谢。
答案 0 :(得分:0)
DatabaseQueryHelper.getInstance().getLesson(chapterId);
此语句无法从数据库中查找数据,因此应检查您的代码......
以及为什么
@Override
protected String doInBackground(String... params) {
lessonList = DatabaseQueryHelper.getInstance().getLesson(chapterId);
return null;
}
它返回null ...
答案 1 :(得分:0)
根据stacktrace,我认为问题是DatabaseQueryHelper.getInstance()返回null;
答案 2 :(得分:0)
你的数据库查询没有返回任何结果,这就是为什么你得到空指针异常...使用if条件检查它...其次你返回null onPostExecute()
方法.insted of返回null返回课程列表
lessonList = DatabaseQueryHelper.getInstance().getLesson(chapterId);
return lessonList;
然后在onPostExecute()中检查是否为null,如
我不知道你的lessonList是一个数组还是什么,但你必须遵循以下方法
if(result!=null)
{
if(result.size()>0)
{
your code
}
答案 3 :(得分:0)
最后我找到了答案。
因more contents added in a single Table cell on local Database.
我在SQLite Manager Ad-Ons的帮助下看到了本地数据库。然后我才知道,在单个表格单元格中添加了更多内容。
这就是它抛出此错误的原因:
VM aborting
Fatal signal 6 (SIGABRT) at 0x0000162c (code=-6), thread 5676
然后我在特定的表格单元格中添加了较少的内容。我没有看到任何崩溃。按照我的预期获得输出。