This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Kubernetes in Action and have Marko Luksa on-line!
See this thread for details.
Win a copy of Kubernetes in Action this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

FATAL EXCEPTION: AsyncTask #1  RSS feed

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how to fix it ?

below are the error message :

05-24 00:50:31.366: E/AndroidRuntime(449): FATAL EXCEPTION: AsyncTask #1
05-24 00:50:31.366: E/AndroidRuntime(449): java.lang.RuntimeException: An error occured while executing doInBackground()
05-24 00:50:31.366: E/AndroidRuntime(449): at android.os.AsyncTask$3.done(AsyncTask.java:200)
05-24 00:50:31.366: E/AndroidRuntime(449): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:274)
05-24 00:50:31.366: E/AndroidRuntime(449): at java.util.concurrent.FutureTask.setException(FutureTask.java:125)
05-24 00:50:31.366: E/AndroidRuntime(449): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:308)
05-24 00:50:31.366: E/AndroidRuntime(449): at java.util.concurrent.FutureTask.run(FutureTask.java:138)
05-24 00:50:31.366: E/AndroidRuntime(449): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
05-24 00:50:31.366: E/AndroidRuntime(449): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
05-24 00:50:31.366: E/AndroidRuntime(449): at java.lang.Thread.run(Thread.java:1019)
05-24 00:50:31.366: E/AndroidRuntime(449): Caused by: java.lang.NullPointerException
05-24 00:50:31.366: E/AndroidRuntime(449): at com.example.androidhive.NewProductActivity$CreateNewProduct.doInBackground(NewProductActivity.java:101)
05-24 00:50:31.366: E/AndroidRuntime(449): at com.example.androidhive.NewProductActivity$CreateNewProduct.doInBackground(NewProductActivity.java:1)
05-24 00:50:31.366: E/AndroidRuntime(449): at android.os.AsyncTask$2.call(AsyncTask.java:185)
05-24 00:50:31.366: E/AndroidRuntime(449): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
05-24 00:50:31.366: E/AndroidRuntime(449): ... 4 more
05-24 00:50:32.355: E/WindowManager(449): Activity com.example.androidhive.NewProductActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@40541df8 that was originally added here
05-24 00:50:32.355: E/WindowManager(449): android.view.WindowLeaked: Activity com.example.androidhive.NewProductActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@40541df8 that was originally added here
05-24 00:50:32.355: E/WindowManager(449): at android.view.ViewRoot.<init>(ViewRoot.java:258)
05-24 00:50:32.355: E/WindowManager(449): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)
05-24 00:50:32.355: E/WindowManager(449): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
05-24 00:50:32.355: E/WindowManager(449): at android.view.Window$LocalWindowManager.addView(Window.java:424)
05-24 00:50:32.355: E/WindowManager(449): at android.app.Dialog.show(Dialog.java:241)
05-24 00:50:32.355: E/WindowManager(449): at com.example.androidhive.NewProductActivity$CreateNewProduct.onPreExecute(NewProductActivity.java:78)
05-24 00:50:32.355: E/WindowManager(449): at android.os.AsyncTask.execute(AsyncTask.java:391)
05-24 00:50:32.355: E/WindowManager(449): at com.example.androidhive.NewProductActivity$1.onClick(NewProductActivity.java:58)
05-24 00:50:32.355: E/WindowManager(449): at android.view.View.performClick(View.java:2485)
05-24 00:50:32.355: E/WindowManager(449): at android.view.View$PerformClick.run(View.java:9080)
05-24 00:50:32.355: E/WindowManager(449): at android.os.Handler.handleCallback(Handler.java:587)
05-24 00:50:32.355: E/WindowManager(449): at android.os.Handler.dispatchMessage(Handler.java:92)
05-24 00:50:32.355: E/WindowManager(449): at android.os.Looper.loop(Looper.java:123)
05-24 00:50:32.355: E/WindowManager(449): at android.app.ActivityThread.main(ActivityThread.java:3683)
05-24 00:50:32.355: E/WindowManager(449): at java.lang.reflect.Method.invokeNative(Native Method)
05-24 00:50:32.355: E/WindowManager(449): at java.lang.reflect.Method.invoke(Method.java:507)
05-24 00:50:32.355: E/WindowManager(449): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
05-24 00:50:32.355: E/WindowManager(449): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
05-24 00:50:32.355: E/WindowManager(449): at dalvik.system.NativeStart.main(Native Method)

and its my line code :



thanks for your help ...
 
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

I have added CODE tags to your post to make it easier to read the code, and to the line numbers.

So there's a NPE in line 101. If the line numbers are accurate (please tell us whether or not they are), then the "json" variable might be null (please confirm whether or not it is).

I guess JSONParser.makeHttpRequest might return null, and your code does not check for that. But that class and that method are not part of the Android API, so we don't know what it does.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!