Open Side Menu Go to the Top
Register
Any Android developers here? Any Android developers here?

06-13-2016 , 10:52 AM
I have an Android app and in the console it gives you the stack traces of the crashes. I have my mappings uploaded to the system to deobfuscate the proguard, but they are so ambiguous. I am really struggling on many of these to figure out exactly where the crash is happening as all it gives you is basically a general location. And I cannot seem to duplicate the errors. An example is below.

So my question to other Android developers, how do you handle these situations?


Code:
java.lang.NullPointerException
	at android.widget.ArrayAdapter.init(ArrayAdapter.java:310)
	at android.widget.ArrayAdapter.<init>(ArrayAdapter.java:153)
	at com.clashtoolkit.clashtoolkit.adapters.CustomArmyAdapter.<init>(CustomArmyAdapter.java)
	at com.clashtoolkit.clashtoolkit.ui.CustomArmyFrag.newInstance(CustomArmyFrag.java)
	                                                   onCreate(CustomArmyFrag.java)
	                                                   onCreateView(CustomArmyFrag.java)
	                                                   setArrayAdapter(CustomArmyFrag.java)
	                                                   onResponse(CustomArmyFrag.java)
	at com.clashtoolkit.clashtoolkit.ui.CustomArmyFrag.newInstance(CustomArmyFrag.java)
	                                                   onCreate(CustomArmyFrag.java)
	                                                   onCreateView(CustomArmyFrag.java)
	                                                   setArrayAdapter(CustomArmyFrag.java)
	                                                   onResponse(CustomArmyFrag.java)
	at com.android.volley.toolbox.JsonRequest.deliverResponse(JsonRequest.java)
	                                          parseNetworkResponse(JsonRequest.java)
	at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java)
	at android.os.Handler.handleCallback(Handler.java:733)
	at android.os.Handler.dispatchMessage(Handler.java:95)
	at android.os.Looper.loop(Looper.java:146)
	at android.app.ActivityThread.main(ActivityThread.java:5511)
	at java.lang.reflect.Method.invokeNative(Method.java)
	at java.lang.reflect.Method.invoke(Method.java:515)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
	at dalvik.system.NativeStart.main(NativeStart.java)
Any Android developers here? Quote
06-14-2016 , 06:04 PM
i dunno if it helps, but i just had to figure out a somewhat similar null pointer exception. Tutorial I'm doing has you change the buttons you'd normally use into ImageButtons as a sort of extra credit deal.

Later, you're learning how to mess with rotations and multiple layouts, and they have you remove layout code for one of the two buttons you changed. Rotating the device gave a null pointer exception, because the other button doesn't exist in landscape ldo.

I dunno if it works in the normal tutorial, with just buttons, but it damn sure doesn't with ImageButtons.
Any Android developers here? Quote
06-15-2016 , 07:01 AM
Looks like you're crashing during a response to a volley web request? Does that seem right? Are you trying to interact with offscreen UI in this response? Also, only perform UI operations on the UI thread.
Any Android developers here? Quote
06-15-2016 , 10:52 AM
Quote:
Originally Posted by Noodle Wazlib
i dunno if it helps, but i just had to figure out a somewhat similar null pointer exception. Tutorial I'm doing has you change the buttons you'd normally use into ImageButtons as a sort of extra credit deal.

Later, you're learning how to mess with rotations and multiple layouts, and they have you remove layout code for one of the two buttons you changed. Rotating the device gave a null pointer exception, because the other button doesn't exist in landscape ldo.

I dunno if it works in the normal tutorial, with just buttons, but it damn sure doesn't with ImageButtons.
I appreciate the response, but my trouble is really figuring out where the null pointer is in the group of methods named.
Any Android developers here? Quote
06-15-2016 , 10:56 AM
Quote:
Originally Posted by maxtower
Looks like you're crashing during a response to a volley web request? Does that seem right? Are you trying to interact with offscreen UI in this response? Also, only perform UI operations on the UI thread.
The volley request is not on the UI, but UI is built after the response. I know the general area, my biggest trouble is knowing exactly when the null pointer happens. And it is tough to tell from these stack traces.

I have tried to duplicate the error, even by putting my phone into airplane mode so I don't get a response.

You are probably correct though that it has something to do with the UI thread being called before the response is finished or something. Using multi threads can definitely be tricky when you are trying to have things happen in sequential order.
Any Android developers here? Quote
06-18-2016 , 05:20 AM
Quote:
Originally Posted by Jibninjas
Using multi threads can definitely be tricky when you are trying to have things happen in sequential order.
This sounds like you are trying to treat aysnc code like its synchronous [without knowing anything about android]. If that is the case, you are basically guaranteed to fail.
Any Android developers here? Quote
06-19-2016 , 09:10 AM
Quote:
Originally Posted by Jibninjas
You are probably correct though that it has something to do with the UI thread being called before the response is finished or something. Using multi threads can definitely be tricky when you are trying to have things happen in sequential order.
Without knowing more about your app/code, this advice may not be relevant. You probably want to set up the UI to point to a data source that is decoupled from the volley response. The array adapter is crashing on a null pointer. So a simple example would be like this:

initialize UI
initialize empty array
attach array to ArrayAdapter
attach ListView to ArrayAdapter
create data binding or notify/observe on array
in the binding/observing method call
adapter.notifyDataSetChanged()
make volley request
in volley response update the empty array.
Any Android developers here? Quote
06-19-2016 , 10:36 AM
Quote:
Originally Posted by maxtower
Without knowing more about your app/code, this advice may not be relevant. You probably want to set up the UI to point to a data source that is decoupled from the volley response. The array adapter is crashing on a null pointer. So a simple example would be like this:

initialize UI
initialize empty array
attach array to ArrayAdapter
attach ListView to ArrayAdapter
create data binding or notify/observe on array
in the binding/observing method call
adapter.notifyDataSetChanged()
make volley request
in volley response update the empty array.
Thank you for the advice. I will take a look at the code and make the changes. I hadn't thought about just initializing an empty array.
Any Android developers here? Quote
06-19-2016 , 11:42 AM
Looking at it again, I believe originally I did try that and ran into some issues initializing a blank adapter. I will try again though.
Any Android developers here? Quote
06-20-2016 , 10:03 AM
Quote:
Originally Posted by Jibninjas
Thank you for the advice. I will take a look at the code and make the changes. I hadn't thought about just initializing an empty array.
You could also check the array before initializing to see if the volley request has already put some data in there, depending on your implementation.
Any Android developers here? Quote

      
m