Android Tutorial Using CustomBuildAction to deploy to multiple devices at once

Discussion in 'Tutorials & Examples' started by Erel, May 20, 2014.

  1. Erel

    Erel Administrator Staff Member Licensed User

    This tutorial will demonstrate how you can use CustomBuildAction attribute to deploy to multiple connected devices at once.

    The "additional" devices should be connected in USB debug mode. This allows us to call the adb tool, which is part of Android SDK, to install the package and run it on each of the devices.

    We will limit this feature to release deployments as debug deployments must run with a device that is actively connected to the IDE.

    The first step is to find the IDs of the connected device by running adb devices:

    [​IMG]

    In this case we have two devices connected through ADB (one of them is the emulator) and another device connected with B4A-Bridge.

    We need to add two build actions for each device. One action will install the APK and the second will run it.

    The actions will be added before the installation step (step #4).

    Code:
    #If RELEASE
       'emulator
       #CustomBuildAction: 4, c:\android-sdk-windows7\platform-tools\adb.exe, -s emulator-5554 install -r 1.apk
       #CustomBuildAction: 4, c:\android-sdk-windows7\platform-tools\adb.exe, -s emulator-5554 shell am start -a android.intent.action.MAIN -n b4a.example/.main -f 0x10000000 -c android.intent.category.LAUNCHER
      'device
       #CustomBuildAction: 4, c:\android-sdk-windows7\platform-tools\adb.exe, -s 04cf0a951c8934fc install -r 1.apk
       #CustomBuildAction: 4, c:\android-sdk-windows7\platform-tools\adb.exe, -s 04cf0a951c8934fc shell am start -a android.intent.action.MAIN -n b4a.example/.main -f 0x10000000 -c android.intent.category.LAUNCHER
    #End If
    There are four values that you need to update in the above code:
    - full path to adb.exe
    - device serial name after -s parameter
    - The apk file name (here it is 1.apk)
    - The package name (here it is b4a.example)


    In the device selection dialog we will choose the B4A-Bridge connected device:

    [​IMG]

    Now we can easily test the same app on multiple connected devices.

    Note that there is a third-party extension to B4A-Bridge that provides a different method for a similar feature: https://play.google.com/store/apps/details?id=com.wordpress.themr23.b4abridge.cmwrelay&hl=en
     
    davelew1s, mr23, DonManfred and 2 others like this.
  2. Informatix

    Informatix Expert Licensed User

    Cumbersome but working. One million thanks. Is there a trick to avoid the dialog?
     
  3. Erel

    Erel Administrator Staff Member Licensed User

    Which one? The device selection dialog?

    You can use Alt + 3 (background compilation).

    It is a bit cumbersome to set it. However it is only required once (and shouldn't take more than 5 minutes).
    You can use different build configurations to customize it.
     
    Informatix likes this.
  4. Informatix

    Informatix Expert Licensed User

    Of course ! :)
     
  5. Gunther

    Gunther Active Member Licensed User

    MultiBridge.png

    Dear All,

    you may use also this small little software attached to let the IDE connect to many devices at once. This what I am using to overcome with the connecting to multiple devices at once. Transfer of APKs is working fine.

    You need Wifi and the B4A-Bridge Plus to let it work. https://play.google.com/store/apps/details?id=anywheresoftware.b4a.b4abridge_gg&hl=en

    Let your IDE connect to IP 127.0.0.1 (localhost) and than you will start the B4A-Bridge Plus-App on each device. They will add themself to the Multibridge and so to the IDE.

    If a device is no longer connected than just press 'F2' in the IDE or press the stop and start button on the device to re-connect.

    As you see the software is in the middle of its way to be ready for all features.
    Funny things you will see by using the designer. This is not completed so far, as well as the Rapide developer. This is tricky and needs some more Titel, therefore the version number is below 1.0!
    The software was done in VB6 so you will need the dlls of VB6. If you don't have that I may send you the Installation-Version of this software via PM since the size will exceed the upload limit.

    Bye4now, Gunther
     

    Attached Files:

    Last edited: Apr 7, 2015
    ellpopeb4a likes this.
  6. themr23

    themr23 Member Licensed User

    Although this thread is old, I just encountered the problem of not being able to connect adb over usb, and want to share the helpful information I found.
    I'm using a new Windows 10 computer, and in my case, my LG G6.
    Although everything was set up according to searched information in the forum, I needed to set my phone in Charging Only mode.

    This helped
    https://stackoverflow.com/questions/24685768/lg-device-not-listed-in-adb-devices
     
    Last edited: Jul 2, 2018
Loading...
  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