我的Logcat中的这个错误意味着什么

时间:2014-04-06 12:23:02

标签: android performance android-logcat

我有问题要理解我的Logcat中的错误,你能帮我解决一下我该如何解决这个问题。

    04-06 08:17:54.738: E/AndroidRuntime(4491): FATAL EXCEPTION: AsyncTask #1
    04-06 08:17:54.738: E/AndroidRuntime(4491): java.lang.RuntimeException: An error   occured while executing doInBackground()
04-06 08:17:54.738: E/AndroidRuntime(4491):     at android.os.AsyncTask$3.done(AsyncTask.java:299)
04-06 08:17:54.738: E/AndroidRuntime(4491):     at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
04-06 08:17:54.738: E/AndroidRuntime(4491):     at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
04-06 08:17:54.738: E/AndroidRuntime(4491):     at java.util.concurrent.FutureTask.run(FutureTask.java:239)
04-06 08:17:54.738: E/AndroidRuntime(4491):     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
04-06 08:17:54.738: E/AndroidRuntime(4491):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
04-06 08:17:54.738: E/AndroidRuntime(4491):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
04-06 08:17:54.738: E/AndroidRuntime(4491):     at java.lang.Thread.run(Thread.java:841)
04-06 08:17:54.738: E/AndroidRuntime(4491): Caused by: java.lang.NullPointerException: println needs a message
04-06 08:17:54.738: E/AndroidRuntime(4491):     at android.util.Log.println_native(Native Method)
04-06 08:17:54.738: E/AndroidRuntime(4491):     at android.util.Log.e(Log.java:231)
04-06 08:17:54.738: E/AndroidRuntime(4491):     at com.example.logintest.adduser$AssCrounTask.doInBackground(adduser.java:118)
04-06 08:17:54.738: E/AndroidRuntime(4491):     at com.example.logintest.adduser$AssCrounTask.doInBackground(adduser.java:1)
04-06 08:17:54.738: E/AndroidRuntime(4491):     at android.os.AsyncTask$2.call(AsyncTask.java:287)
04-06 08:17:54.738: E/AndroidRuntime(4491):     at java.util.concurrent.FutureTask.run(FutureTask.java:234)
04-06 08:17:54.738: E/AndroidRuntime(4491):     ... 4 more

3 个答案:

答案 0 :(得分:1)

您放入Log的邮件为空。这就写在这里:

Caused by: java.lang.NullPointerException: println needs a message
04-06 08:17:54.738: E/AndroidRuntime(4491):     at android.util.Log.println_native(Native Method)
04-06 08:17:54.738: E/AndroidRuntime(4491):     at android.util.Log.e(Log.java:231)
04-06 08:17:54.738: E/AndroidRuntime(4491):     at com.example.logintest.adduser$AssCrounTask.doInBackground(adduser.java:118)

Log消息中查看您使用的内容。

答案 1 :(得分:1)

正如您的logcat所说

04-06 08:17:54.738: E/AndroidRuntime(4491): Caused by: java.lang.NullPointerException: println needs a message
04-06 08:17:54.738: E/AndroidRuntime(4491):     at android.util.Log.println_native(Native Method)

你有一个NullPointerException,可能你调用了Log.e()并在变量中传递一个空值。

答案 2 :(得分:1)

要向logcat报告崩溃,您应该使用Log.d/v/etc(TAG, Message, Throwable)而不是e.printStackTrace()


无论如何,您的代码崩溃是因为e.getMessage()可能为null而Log不接受null作为消息。

所以将你的行改为

Log.e("MY_APP_error!", "Error!", e);