Android Question Best practices for debugging?

FrankBerra

Active Member
Licensed User
Longtime User
Hi all

My application is growing and getting complicated and it's behaviour sometimes is unpredictable.

Sometimes in relase mode randomly it is crashing. I try to "decrypt" the unfiltered logs but they are not so friendly.

For example a random error says:

B4X:
02-28 09:46:59.151 16172 16172 E AndroidRuntime: FATAL EXCEPTION: main
02-28 09:46:59.151 16172 16172 E AndroidRuntime: Process: test.app, PID: 16172
02-28 09:46:59.151 16172 16172 E AndroidRuntime: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
02-28 09:46:59.151 16172 16172 E AndroidRuntime:     at java.util.ArrayList.get(ArrayList.java:411)
02-28 09:46:59.151 16172 16172 E AndroidRuntime:     at anywheresoftware.b4a.objects.collections.List.Get(List.java:117)
02-28 09:46:59.151 16172 16172 E AndroidRuntime:     at test.app.main._radar_changetext(main.java:8606)
02-28 09:46:59.151 16172 16172 E AndroidRuntime:     at java.lang.reflect.Method.invoke(Native Method)
02-28 09:46:59.151 16172 16172 E AndroidRuntime:     at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
02-28 09:46:59.151 16172 16172 E AndroidRuntime:     at anywheresoftware.b4a.keywords.Common$5$1.run(Common.java:981)
02-28 09:46:59.151 16172 16172 E AndroidRuntime:     at anywheresoftware.b4a.BA.setActivityPaused(BA.java:398)
02-28 09:46:59.151 16172 16172 E AndroidRuntime:     at test.app.main.afterFirstLayout(main.java:106)
02-28 09:46:59.151 16172 16172 E AndroidRuntime:     at test.app.main.access$000(main.java:17)
02-28 09:46:59.151 16172 16172 E AndroidRuntime:     at test.app.main$WaitForLayout.run(main.java:80)
02-28 09:46:59.151 16172 16172 E AndroidRuntime:     at android.os.Handler.handleCallback(Handler.java:751)
02-28 09:46:59.151 16172 16172 E AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:95)
02-28 09:46:59.151 16172 16172 E AndroidRuntime:     at android.os.Looper.loop(Looper.java:154)
02-28 09:46:59.151 16172 16172 E AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:6209)
02-28 09:46:59.151 16172 16172 E AndroidRuntime:     at java.lang.reflect.Method.invoke(Native Method)
02-28 09:46:59.151 16172 16172 E AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
02-28 09:46:59.151 16172 16172 E AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

Where the crash is fired?
Here i see "changetext" that it is a sub in the app but it not contains any List/Array...so which array is referring to? Reference "ArrayList.java:411" is not helping me in any way...

My simple question is: how can i debug easily my app? Is there some lib/hack or whatever that can help me in debugging a release version?
(Putting Log("bla bla bla") everywhere is not a good solution due to the size of the project (more than 15000 rows of code))

Do you think that doing reverse-engineering on the compiled apk can help me to find the problem? Any suggestion about a good reverse-engineering tool?

Community Help and tips will be very apreciated
 
Last edited:

lemonisdead

Well-Known Member
Licensed User
Longtime User
Hello,
that it is a sub in the app but it not contains any List/Array...
Open the generated .java file with a text editor (for ex Notepad++ or SublimeText, able to display text lines numbers). The Java and B4X code and lines will be listed in. I would check lines 411 and 117 to find what does what.
The generated .java files are in your project's folder \ Objects \ src \ [name of your package] \ and here for example, main.java
Or perhaps do you include some classes ?
how can i debug easily my app?
Using the DEBUG Mode
or whatever that can help me in debugging a release version?
Try, Catch, Logging ?
Do you think that doing reverse-engineering on the compiled apk can help me to find the problem?
Yes it could but you would get Java code in return. You would have to compare with the .java files source code generated by B4A (not really time saver, I do more prefer to DEBUG the app before anything else)
Any suggestion about a good reverse-engineering tool?
You should make a Google search because reverse-engineering is so bad
 
Upvote 0

lemonisdead

Well-Known Member
Licensed User
Longtime User
Well, made some test and this makes me wonder
test.app.main._radar_changetext(main.java:8606)
Do you use any included library (I made a search with radar)
 
Upvote 0

FrankBerra

Active Member
Licensed User
Longtime User
Yes, the sub is really simple

B4X:
Sub Radar_ChangeText 
       Radar_LabelDetect.Text="Contacting server..."
End Sub

Anyway this is just an example of multiple crashes that i can't spot out, that's why i am searching for an alternative for debugging release versions
 
Upvote 0
Top