Android Tutorial Rapid Debugger

Discussion in 'Tutorials & Examples' started by Erel, Oct 1, 2013.

  1. Erel

    Erel Administrator Staff Member Licensed User

    Basic4android v3.0 includes a new debugger named rapid debugger.


    The rapid debugger is a very sophisticated debugger with features not available in any other native Android development tool.

    The rapid debugger is an important addition to Basic4android. It will increase your productivity as it makes the "write code -> test result" cycle much quicker.

    Using this deployment mode is similar to using the standard debugger ("legacy" debugger).

    Rapid Debugger advantages

    • Very quick compilation and installation. Usually in less than one or two seconds.
    • In most cases (after the first installation) there is no need to reinstall the APK. This means that the deployment is much quicker. With B4A-Bridge there is no need to approve the installation.
    • Hot code swapping (edit and continue). You can modify the code while the app runs, hit Save and the code will be updated.
    • Powerful variables browser:

    • Watch Expressions (v3.50):

      Allows you to evaluate expressions during breakpoints.

    • The runtime execution in this mode is slower. In some cases it is slightly slower and in others it can be significantly slower. The rapid debugger is not suitable for debugging "real-time" games or CPU intensive tasks. This is why the legacy debugger is kept.
      Starting from v3.50 the runtime performance of the rapid debugger is close to Release mode.

    • Hot code swapping is very powerful. You can even add subs or modify existing subs. However you cannot add or remove global variables.
    • Unlike the legacy debugger, the app cannot run when the IDE is not connected. It will wait for 10 seconds for the IDE to connect and then exit.
    Last edited: Mar 6, 2014
    ilan, Monkeh, bigbadfred and 6 others like this.
  2. Erel

    Erel Administrator Staff Member Licensed User

    Under the hood (simplified view)

    So how does the rapid debugger work?

    I will start with an explanation about the legacy debugger. When you compile in Debug (legacy) the B4A compiler creates a regular Android APK. However in addition to the program code the compiler generates instrumented code. This means that for each line it adds a runtime check to test whether there is a breakpoint on that line. If there is a breakpoint the program pauses by showing a modal dialog and the variables data is sent to the IDE over the connection.

    The rapid debugger works differently. When you compile your code it creates two applications. A device application (shell) and a standard Java application (debugger engine).

    Your code resides in the debugger engine. The debugger engine runs on the desktop. The shell application is like a mini-virtual machine. The debugger engine connects to the shell app and sends the instructions to the shell app. The interesting part of this is that your code is not executed on the device. It is executed on the desktop.
    In most cases the shell app can be reused. If for example you add a new file or edit the manifest file with the manifest editor then the compiler will create a new shell app and will reinstall it automatically during compilation.

    The standard JVM is more powerful than Android Dalvik machine. It allows for example to load classes at runtime. This is how code swapping is supported.
  3. Computersmith64

    Computersmith64 Well-Known Member Licensed User

    Sounds awesome Erel! Having the ability to make code changes during debug execution will be fantastic & something I have really been missing since I started using B4A. I'm going to download v3.00 & try it today!

    UPDATE: Having used it already today - it's great! I did run into one issue because I was trying to test some network comms on 2 devices. I had to run one device on the "legacy" debug code & the other on the "rapid" debug because of the need for rapid debug to connect to the IDE. Apart from that, it works great & is very fast after the initial compile & install.
    Last edited: Oct 1, 2013
  4. Creaky

    Creaky Member Licensed User

    Bloody awesome!
    My compliments Erel!
    krzyszp likes this.
  5. joneden

    joneden Active Member Licensed User

    Ah this was one of the major issues that I had with debugging. Great news - well done. Installing beta now!
  6. JohnC

    JohnC Well-Known Member Licensed User

    Very cool - will check it out in a few days.
  7. Jose Miranda

    Jose Miranda Member Licensed User

    This is awesome! Im going to check it tonight. Thanks!
  8. dreamworld

    dreamworld Active Member Licensed User

    This is a great achievement!

    But if you can enable B4A to debug multi threads, B4A is a full development tool.
  9. Monkeh

    Monkeh Member Licensed User

    Awesome! This will make testing different layouts and schemes much less like a chore.
    Cheers Erel. =)
  10. stevel05

    stevel05 Expert Licensed User


    I always knew you were a genius, this is the last bit of proof!

  11. Jim Brown

    Jim Brown Active Member Licensed User

    Just a reminder for people who may be using the standard Android Emulator, try using the must faster GenyMotion instead.
    Shadow&Max and Eduard like this.
  12. Erel

    Erel Administrator Staff Member Licensed User

    Did you try the rapid debugger with GenyMotion?
  13. klaus

    klaus Expert Licensed User

    I am pleased to give my feeling after having worked some hours on a big project with the Rapid Debugger in 'real conditions' fine tuning the drawing of a sketch. I could do it only since beta version 8.
    It is a real pleasure working with it and a HUGE efficiency improvement in developpment time.
    Many many thank's Erel !

    Best regards.
    Last edited by a moderator: Oct 9, 2013
  14. Erel

    Erel Administrator Staff Member Licensed User

    Thank you klaus. Your feedback is very important for me :)
  15. gpe

    gpe Member Licensed User

    I couldn't believe it!
    Just received the e-mail, I cannot wait to try it hoping to spare hours of work.
    As a matter of fact, my "method" of programming is "try and hope it works ! "
    Thanks Erel
    stari likes this.
  16. Bas Hamstra

    Bas Hamstra Member Licensed User

    I did a quick test with GenyMotion and the rapid debugger seems to work fine! And fast too! GM and RD are two GREAT additions! Since the old debugger did not work with HAXM image I had to start another ultraslow emulator for debugging. Not anymore!

    If you like to develop on your desktop, get Genymotion now! It boots in seconds and runs faster than your phone and seems to integrate fine with B4A.

    Thanks Erel and Jim

    Erel likes this.
  17. Eduard

    Eduard Active Member Licensed User

    Erel, thanks very much for the code swapping feature. Very useful, especially on large projects.:)

    I just installed GenyMotion too and tested it. It works really good and I can recommend it to everybody because of it's speed. It's probably a thousand times faster than rapid debug using a bluetooth or wifi bridge. Using wifi bridge in combination with rapid debugger is not working here at all. Way too slow because of latency. GenyMotion is great, it makes rapid debug rapid.

    Unfortunate the version of SQLCipher used in the b4a library will not work with GenyMotion because this uses a x86 cpu. Hope this will be updated, see my post:
  18. Erel

    Erel Administrator Staff Member Licensed User

    This is a very good point. An alternative emulator such as GenyMotion should work great with the rapid debugger as the network communication is much faster.
  19. tchart

    tchart Active Member Licensed User

    Good to know, I just tried my time keeping app and it was counting very slowly.

    Also I build my UI through code. I noticed that the text size etc doesn't update when I hit Ctrl+S. I suspect the UI is not refreshed? If I stop debugging and start it again its very quick and the UI changes are there.
  20. Erel

    Erel Administrator Staff Member Licensed User

    Not exactly. The code is updated. However if Activity_Create already ran then the changes will not be applied. The changed code is not applied "retroactively".

    You can use the restart app (red arrow) to start the app from the beginning.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice