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

Status
Not open for further replies.
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

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: https://play.google.com/store/apps/details?id=anywheresoftware.b4a.b4abridge

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:

arSsfzqjKtq2_v9Moofj4SgiWWet6WOFH-P1Z2NuxbMo4yB6yqsGaoioptbDdbMCZw4=h900



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:

SS-2016-09-29_09.31.05.png


SS-2016-09-29_09.31.46.png


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:

SS-2012-03-21_10.50.48.png


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

SS-2012-03-21_10.52.17.png


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.

Logs

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


B4A-Bridge source code is available here: http://www.b4x.com/forum/basic4andr...ls/8153-b4a-bridge-source-code.html#post45854

Tip

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

Attachments

  • upload_2016-9-29_9-29-57.png
    upload_2016-9-29_9-29-57.png
    14.3 KB · Views: 6,230
Last edited:

DeSche

New Member
Licensed User
Do you see any error message on the device?

Have you tried to uninstall the existing app?

Device show only "Umfassende Prüfung der Apps nach Bedrohnung", meaning that the app will be checked to have no dangerous parts.

Than the device say: "Vor der Installation mit Lookout", meaning "before Installation with lookout".

I've re-installier B4A bride and i've also deleted the old version of my app on the Phone
 
Last edited:

Mikonios

Active Member
Licensed User
Longtime User
Crash with B4A 7.30 and B4A-Bridge 2.31 ECONNRESET
(I put this here, because when I create a new conversation it asks me for participants and it does not allow me to insert any) !!!

I often happen with the new version B4A 7.30 when compiling a version, and after transfer with B4-Bridge v2.31, and after installing the application the process stops and crash the application. I am attaching the error log.

This same application and without any modification sometimes compiles the first and other times I have to compile up to 5 or 10 times.
The only way to compile well again is by closing the compiler on windows, closing B4A-Bridge and recompiling. And I do not have any problems in my network.

Does this happen to any of you ??
Do you know someone who should ??
Has anyone solved this problem ??
Is there any known solution for this ??
B4X:
'''    Logger connected To:  samsung SM-N9005
'''    --------- beginning of main
'''    ** Activity (main) Create, isFirst = True **
'''    ** Activity (main) Resume **
'''    ** Activity (main) Pause, UserClosed = False **
'''    --------- beginning of system
'''    java.lang.RuntimeException: java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)
'''        at anywheresoftware.b4a.shell.Shell.virtualAssets(Shell.java:168)
'''        at anywheresoftware.b4a.shell.Shell.start(Shell.java:101)
'''        at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:89)
'''        at coco.gas.main.afterFirstLayout(main.java:94)
'''        at coco.gas.main.access$000(main.java:17)
'''        at coco.gas.main$WaitForLayout.run(main.java:80)
'''        at android.os.Handler.handleCallback(Handler.java:739)
'''        at android.os.Handler.dispatchMessage(Handler.java:95)
'''        at android.os.Looper.Loop(Looper.java:145)
'''        at android.app.ActivityThread.main(ActivityThread.java:5938)
'''        at java.lang.reflect.Method.invoke(Native Method)
'''        at java.lang.reflect.Method.invoke(Method.java:372)
'''        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
'''        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
'''    Caused by: java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)
'''        at libcore.io.IoBridge.maybeThrowAfterRecvfrom(IoBridge.java:592)
'''        at libcore.io.IoBridge.recvfrom(IoBridge.java:556)
'''        at java.net.PlainSocketImpl.read(PlainSocketImpl.java:485)
'''        at java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:37)
'''        at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:237)
'''        at java.io.InputStream.read(InputStream.java:162)
'''        at java.io.BufferedInputStream.fillbuf(BufferedInputStream.java:149)
'''        at java.io.BufferedInputStream.read(BufferedInputStream.java:295)
'''        at libcore.io.Streams.readFully(Streams.java:81)
'''        at java.io.DataInputStream.readInt(DataInputStream.java:103)
'''        at anywheresoftware.b4a.shell.Shell.virtualAssets(Shell.java:140)
'''        ... 13 more
'''    Caused by: android.system.ErrnoException: recvfrom failed: ECONNRESET (Connection reset by peer)
'''        at libcore.io.Posix.recvfromBytes(Native Method)
'''        at libcore.io.Posix.recvfrom(Posix.java:161)
'''        at libcore.io.BlockGuardOs.recvfrom(BlockGuardOs.java:250)
'''        at libcore.io.IoBridge.recvfrom(IoBridge.java:553)
'''        ... 22 more
'''    java.lang.RuntimeException: java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)
'''        at anywheresoftware.b4a.shell.Shell.virtualAssets(Shell.java:168)
'''        at anywheresoftware.b4a.shell.Shell.start(Shell.java:101)
'''        at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:89)
'''        at coco.gas.main.afterFirstLayout(main.java:94)
'''        at coco.gas.main.access$000(main.java:17)
'''        at coco.gas.main$WaitForLayout.run(main.java:80)
'''        at android.os.Handler.handleCallback(Handler.java:739)
'''        at android.os.Handler.dispatchMessage(Handler.java:95)
'''        at android.os.Looper.Loop(Looper.java:145)
'''        at android.app.ActivityThread.main(ActivityThread.java:5938)
'''        at java.lang.reflect.Method.invoke(Native Method)
'''        at java.lang.reflect.Method.invoke(Method.java:372)
'''        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
'''        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
'''    Caused by: java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)
'''        at libcore.io.IoBridge.maybeThrowAfterRecvfrom(IoBridge.java:592)
'''        at libcore.io.IoBridge.recvfrom(IoBridge.java:556)
'''        at java.net.PlainSocketImpl.read(PlainSocketImpl.java:485)
'''        at java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:37)
'''        at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:237)
'''        at java.io.InputStream.read(InputStream.java:162)
'''        at java.io.BufferedInputStream.fillbuf(BufferedInputStream.java:149)
'''        at java.io.BufferedInputStream.read(BufferedInputStream.java:295)
'''        at libcore.io.Streams.readFully(Streams.java:81)
'''        at java.io.DataInputStream.readInt(DataInputStream.java:103)
'''        at anywheresoftware.b4a.shell.Shell.virtualAssets(Shell.java:140)
'''        ... 13 more
'''    Caused by: android.system.ErrnoException: recvfrom failed: ECONNRESET (Connection reset by peer)
'''        at libcore.io.Posix.recvfromBytes(Native Method)
'''        at libcore.io.Posix.recvfrom(Posix.java:161)
'''        at libcore.io.BlockGuardOs.recvfrom(BlockGuardOs.java:250)
'''        at libcore.io.IoBridge.recvfrom(IoBridge.java:553)
'''        ... 22 more
'''    java.lang.RuntimeException: java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)
'''        at anywheresoftware.b4a.shell.Shell.virtualAssets(Shell.java:168)
'''        at anywheresoftware.b4a.shell.Shell.start(Shell.java:101)
'''        at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:89)
'''        at coco.gas.main.afterFirstLayout(main.java:94)
'''        at coco.gas.main.access$000(main.java:17)
'''        at coco.gas.main$WaitForLayout.run(main.java:80)
'''        at android.os.Handler.handleCallback(Handler.java:739)
'''        at android.os.Handler.dispatchMessage(Handler.java:95)
'''        at android.os.Looper.Loop(Looper.java:145)
'''        at android.app.ActivityThread.main(ActivityThread.java:5938)
'''        at java.lang.reflect.Method.invoke(Native Method)
'''        at java.lang.reflect.Method.invoke(Method.java:372)
'''        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
'''        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
'''    Caused by: java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)
'''        at libcore.io.IoBridge.maybeThrowAfterRecvfrom(IoBridge.java:592)
'''        at libcore.io.IoBridge.recvfrom(IoBridge.java:556)
'''        at java.net.PlainSocketImpl.read(PlainSocketImpl.java:485)
'''        at java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:37)
'''        at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:237)
'''        at java.io.InputStream.read(InputStream.java:162)
'''        at java.io.BufferedInputStream.fillbuf(BufferedInputStream.java:149)
'''        at java.io.BufferedInputStream.read(BufferedInputStream.java:295)
'''        at libcore.io.Streams.readFully(Streams.java:81)
'''        at java.io.DataInputStream.readInt(DataInputStream.java:103)
'''        at anywheresoftware.b4a.shell.Shell.virtualAssets(Shell.java:140)
'''        ... 13 more
'''    Caused by: android.system.ErrnoException: recvfrom failed: ECONNRESET (Connection reset by peer)
'''        at libcore.io.Posix.recvfromBytes(Native Method)
'''        at libcore.io.Posix.recvfrom(Posix.java:161)
'''        at libcore.io.BlockGuardOs.recvfrom(BlockGuardOs.java:250)
'''        at libcore.io.IoBridge.recvfrom(IoBridge.java:553)
'''        ... 22 more
'''    java.lang.RuntimeException: java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)
'''        at anywheresoftware.b4a.shell.Shell.virtualAssets(Shell.java:168)
'''        at anywheresoftware.b4a.shell.Shell.start(Shell.java:101)
'''        at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:89)
'''        at coco.gas.main.afterFirstLayout(main.java:94)
'''        at coco.gas.main.access$000(main.java:17)
'''        at coco.gas.main$WaitForLayout.run(main.java:80)
'''        at android.os.Handler.handleCallback(Handler.java:739)
'''        at android.os.Handler.dispatchMessage(Handler.java:95)
'''        at android.os.Looper.Loop(Looper.java:145)
'''        at android.app.ActivityThread.main(ActivityThread.java:5938)
'''        at java.lang.reflect.Method.invoke(Native Method)
'''        at java.lang.reflect.Method.invoke(Method.java:372)
'''        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
'''        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
'''    Caused by: java.net.SocketException: recvfrom failed: ECONNRESET (Connection reset by peer)
'''        at libcore.io.IoBridge.maybeThrowAfterRecvfrom(IoBridge.java:592)
'''        at libcore.io.IoBridge.recvfrom(IoBridge.java:556)
'''        at java.net.PlainSocketImpl.read(PlainSocketImpl.java:485)
'''        at java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:37)
'''        at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:237)
'''        at java.io.InputStream.read(InputStream.java:162)
'''        at java.io.BufferedInputStream.fillbuf(BufferedInputStream.java:149)
'''        at java.io.BufferedInputStream.read(BufferedInputStream.java:295)
'''        at libcore.io.Streams.readFully(Streams.java:81)
'''        at java.io.DataInputStream.readInt(DataInputStream.java:103)
'''        at anywheresoftware.b4a.shell.Shell.virtualAssets(Shell.java:140)
'''        ... 13 more
'''    Caused by: android.system.ErrnoException: recvfrom failed: ECONNRESET (Connection reset by peer)
'''        at libcore.io.Posix.recvfromBytes(Native Method)
'''        at libcore.io.Posix.recvfrom(Posix.java:161)
'''        at libcore.io.BlockGuardOs.recvfrom(BlockGuardOs.java:250)
'''        at libcore.io.IoBridge.recvfrom(IoBridge.java:553)
'''        ... 22 more
 
Status
Not open for further replies.
Top