Android Tutorial B4A-Bridge a new way to connect to your device

Discussion in 'Tutorials & Examples' started by Erel, Feb 24, 2011.

Thread Status:
Not open for further replies.
  1. Erel

    Erel Administrator Staff Member Licensed User

    There are several options to develop with B4A:
    - Android emulator or a VM.
    - Connect to a real device in USB debugging mode
    - Connect to a real device with B4A-Bridge.

    I recommend starting with B4A-Bridge, which is the simplest connection method.

    USB Debug Mode

    You will need to first configure your device to support USB debugging (Settings - Developer - USB debugging).

    In order to reveal the developer settings you should follow these instructions:
    - Choose Settings - About Phone
    - Find the Build Number entry and click on it 7 times.
    - On many devices you need to set the USB connection type to MTP or PTP.

    Not all devices support USB debugging.


    B4A-Bridge is made of two components. One component runs on the device and allows the second component which is part of the IDE to connect and communicate with the device.
    The connection is done over the local network or with a Bluetooth connection.

    Once connected, B4A-Bridge supports all of the IDE features which include: installing applications, viewing the logs, debugging and the visual designer (taking screenshots is not supported).

    Android doesn't allow applications to quietly install other applications, therefore when you run your application using B4A-Bridge you will see a dialog asking you to approve the installation.

    Getting started with B4A-Bridge
    1. First you need to install B4A-Bridge on your device.
    B4A-Bridge can be downloaded from Google Play:

    Note that you need to allow installation of applications from "Unknown sources". This is done by choosing Settings from the Home screen - Manage Applications.

    2. Run B4A-Bridge on your device. It will display a screen similar to:


    3. Connect the IDE to the device

    Go to Tools -> B4A-Bridge -> Connection -> New IP

    You will be asked to enter the device IP address. The IP is displayed on the device.

    The status bar at the bottom of the screen shows the current status:



    That's it.

    When B4A-Bridge gets connected it first checks if the designer application needs to be updated. In that case it will first install the designer application.

    B4A-Bridge keeps running as a service until you press on the Stop button.
    You can always reach it by opening the notifications screen.

    As mentioned above, when you run an application you are required to approve the installation. You will usually see the following screens:


    Note that the Internet permission is automatically added in debug mode.


    In the above dialog you should choose Open to start the application.
    If you try to install an existing application signed with a different key, the install will fail (without any meaningful message). You should first uninstall the existing application. Go to the home screen - Settings - Applications - Manage applications - choose the application - Uninstall.

    Once you finished developing you should press on the Stop button in order to save battery.


    With B4A-Bridge the logs will only appear in release mode if you add this line to the main module:
    #BridgeLogger: True
    It is better to comment this line before submitting your app to Google Play.

    B4A-Bridge source code is available here:


    You can click on the B4A-Bridge status in the IDE to connect or disconnect the bridge.

    Attached Files:

    Last edited: Nov 11, 2019 at 7:32 AM
  2. Cableguy

    Cableguy Expert Licensed User

    Am I correct to assume that this will be using gprs data conection in the IDE to Device conection? If so, tis means that this conection will have a cost, according to your carrier Charging fees...
    I remember reading somewere about a way to connect using Bluetoorh, is this possible with this app?
  3. Erel

    Erel Administrator Staff Member Licensed User

    No. B4A-Bridge should be used when you have a wireless network available (both the device and the computer should be connected to the same router).
    Rockefeller Goldman likes this.
  4. Cableguy

    Cableguy Expert Licensed User

    Nice...Would it also be possible to "bridge" multiple devices simultaneasly, with the log, or choose wich one to log from? For those who have 2 or 3 devices, this would mean realtime multi-Screen format debugging...
  5. Erel

    Erel Administrator Staff Member Licensed User

    You can only "bridge" to a single device. However you can have multiple connections with 'adb'. So you can work with one device for running the code (with B4A-Bridge) and also be connected to the emulator with the designer.
  6. Cableguy

    Cableguy Expert Licensed User

    Ok, so can you please add-it to the Bridge wish list?
  7. Cableguy

    Cableguy Expert Licensed User

    B4A 1.3 and B4A Bridge First impressions...

    Speed! I could almost say that this is much Faster than the previous version...very much faster...
    The Bridge works very smothly, and the connection is easy to stablish..
    I have one wixh for the Bridge, On the device side...That is to KeepALive the screen when connected...Or give the user that option..
    Everything else is perfect..

    Thanks EREL
    Last edited: Feb 27, 2011
  8. Erel

    Erel Administrator Staff Member Licensed User

    Thank you Cableguy.
    toby likes this.
  9. asawyer13

    asawyer13 Member Licensed User

    Has V1.3 and the bridge been released?

    I didn't see any emails, so just wondering.

  10. alfcen

    alfcen Well-Known Member Licensed User

    B4A Bridge

    Installed and tested. Works like a charm with a Sharp IS03 phone over my home WiFi. No extra wishes, invaluable IDE enhancement that embraces phones with poor or no ADB performance! Looking forward to what else is new in V 1.3.

  11. Erel

    Erel Administrator Staff Member Licensed User

    V1.3 will be released tomorrow.
  12. slydog43

    slydog43 Member Licensed User

    nice, cant wait.
  13. TOB

    TOB Member Licensed User

    Same here :icon_clap: :)
  14. metrick

    metrick Active Member Licensed User

    Speed increase, load faster.
  15. GabrielM

    GabrielM Member Licensed User

    just superb on Spica/Froyo :)

    Thank you Erel
  16. mistermentality

    mistermentality Active Member Licensed User

    The Bridge works flawlessly on my GT540, and quickly too. Thanks :)

  17. susu

    susu Well-Known Member Licensed User

    Oh, B4A Bridge doesn't work! I installed B4A Bridge from Market. I run it and it show my IP is I select Tools/B4A Bridge/Connect menu in IDE and enter this IP but it still disconnected.

    Ps: My device is Android 2.1 and it run the same function app name WiFi File Explorer very well.
  18. Erel

    Erel Administrator Staff Member Licensed User

    Does the device application show any message?
    It should display: "waiting for connections"
  19. susu

    susu Well-Known Member Licensed User

    On my device:

    My IP:
    Status: Disconnected.
    Waiting For connections.


    B4A-Bridge v1.00
  20. Erel

    Erel Administrator Staff Member Licensed User

    Are you able to connect with ADB to this device? Maybe there will be more information in the logs.
    Another possible issue may be related to the network / firewall which doesn't allow you to make an outgoing connection from the desktop.

    You can start the IDE from the command line and add -log parameter:
    Basic4android -log
    It will write log messages to C:\Temp\log.txt. Try to connect B4A-Bridge and then check if there are any errors in the log.
Thread Status:
Not open for further replies.
  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