Android Tutorial Debugging android applications

Tutorial covering the new "Rapid Debugger" deployment mode is available here:
Rapid Debugger


This tutorial explains the debugging features added in Basic4android v1.50 as well as the other related tools.
The debug option is here:
SS-2012-02-09_14.28.02.png


The debugging code allows the IDE to connect to the program and inspect it while it runs.
When the program starts it will wait for up to 10 seconds for the IDE to connect. Usually the IDE will connect immediately. However if you run your program manually from the phone you will see it waiting.
The name of the compiled APK file will end with _DEBUG.apk. You should not distribute this apk file as it contains the debugging code which adds a significant overhead.


When we run the program in debug mode the IDE will open the debugger module at the bottom of the screen:

debugger_tutorial2.png


The debugging module contains three sections: subs stack, global variables and local variables. These sections show the data when the program is paused. Note that you can also see the variables data by hovering with the mouse over a variable name in the code.
Above the subs stack section there are useful buttons for continuing the execution, stepping to the next line, pausing execution and stopping the program. There is also an icon which tells us whether the debugger is connected. Double clicking on this icon will disconnect the debugger without killing the program.
Note that there is also a Debug menu which additionally includes Step Over (executes the next line without breaking on inner sub calls) and Step Out (gets out of the current sub and breaks) items.
The code editor is read only while the debugging module is visible.

Breakpoints - You can mark lines of codes as breakpoints. This is done by pressing on the grey area left of the line.
The program will pause when it reaches a breakpoint and will allow you to inspect the current state.

Logging - The Logs tab at the right pane is very useful. It shows messages related to the components life cycle and it can also show messages that are printed with the Log keyword. You should press on the Connect button to connect to the device logs. Note that there is a Filter checkbox. When it is checked you will only see messages related to your program. When it is unchecked you will see all the messages running in the system. If you are encountering an error and do not see any relevant message in the log, it is worth unchecking the filter option and looking for an error message.
Note that the log is maintained by the device. When you connect to a device you will also see previous messages.

Notes about the debugger:
- Breakpoints in the following subs will be ignored: Globals, Process_Globals and Activity_Pause.
- Services - Breakpoints that appear after a call to StartService will be ignored. Breakpoints set in Service_Create and Service_Start will pause the program for up to a specific time (about 12 seconds). This is to avoid the OS from killing the Service.
- Events that fire when the program is paused will be executed. Breakpoints in the event code will be ignored (only when the program is already paused).
- The data sent from the device to the IDE is limited in size. Long strings may be truncated.
 
Last edited:

zity

Member
Licensed User
Longtime User
Note that as of V1.80, you don't have the debug options in the Project menu.
You need to select 'Debug' mode in the dropdown that is in the middle of the top toolbar.
 

aardsoft

Member
Licensed User
Longtime User
No attach debugger in Project drop down

Hi, From what I am reading there should be the option to attach a debugger in the Project drop down list. My list ends with 'run last deployment Alt+4'. I have checked the 'About' and the version I am using is V1.92 which I believe is the latest. What am I doing wrong.
regards

Aardsoft
 

macnlkc

Member
Licensed User
Longtime User
No Debug information Displayed

I have the dropdown box in the Debug option yet I get no Debug information when running my application. Any thoughts on what I am doing incorrectly?
 

macnlkc

Member
Licensed User
Longtime User
It does connect.

I can pause, step, resume, etc. but the IDE shows no information under the Sub Stack, Global Variables or Local Variables panels.

When I click on the Blue Twistie next to the DropDown box (selected with Debug chosen), the app brings up the Compile and Debug Modal window. I get the typical compiling information and then the Completed Successfully message.

On the target device (connected via Wireless) then notes that the application will replace another application and that all previous data will be saved. I click OK. I then Install the application. I am then asked to Open the application.

A modal window then displays it is "waiting for the IDE Debugger to connect". It shows that it is connected because I have full control from the desktop to the device. However, all the Debug panels are empty.
 
Last edited:

macnlkc

Member
Licensed User
Longtime User
BTW, I tested this via the AVD and it also does not show any debugging data. So the whole debugging thing doesn't appear to be working.

I have also tested this on a separate machine that is running the trial version 1.92 and it doesn't seem to work on it either.

FYI: I did notice that the Status Line on the bottom of the IDE denotes Debug mode: Text Editor is read only. So that would assume that the IDE does understand that it is connected to the device and that Debug mode is operational. It just doesn't seem to be relaying the object data. Hope that helps.
 

peacemaker

Expert
Licensed User
Longtime User
No possibility of remote debugging via Internet ?
please, move my this post from tutorial.
 

peacemaker

Expert
Licensed User
Longtime User
OK, for all: remote control of Android device is now possible by TeamViewer QS app, from the PC software version. Partially remote testing is OK.
 

Mashiane

Expert
Licensed User
Longtime User
Just a quick question on the rapid debugger. Does it warm of variable type mismatch, for example defining a variable as a string but then assign a boolean to it? I understand the code does allow assigning strings to integers etc, but how can one get warnings in cases where a string is assigned a boolean value?
 

Lee Gillie CCP

Active Member
Licensed User
Longtime User
Something I sure miss from Visual Studio is BREAK on EXCEPTION. It's nice to be able to check the call stack and variable values at such a time. It is certainly a time saver.
 
Top