Android Tutorial Running B4A and B4J under Linux with wine - fully functional

I have just managed to install B4A and make it run (including B4ASdkManager) on my Xubuntu 18.04 and, since I have lost two days and one night putting things together, I thought it will be a good idea to share it with this great community :)

Will assume that we have a partition for virtual drives on wine at /virtuals

1. Install last stable version of Wine (4.0) - x86 version
2. Install winetricks for easyer management, this short tutorial will rely on that
3. Create wine prefix for B4X applications:
Run in terminal, under your user, not root
WINEPREFIX="/virtuals/b4x" WINEARCH=win32 wine wineboot
4. Start winetricks:
Run in terminal, under your user, not root
WINEPREFIX="/virtuals/b4x" winetricks
5. Check "Select the default wine prefix" and click "OK"
(obsolete, not for wine 4.0) 6. Run winecfg and make sure Windows version is set to XP
6. Run winecfg and make sure Windows version is set to Windows 7
7. Check "Install a Windows DLL or component" and click "OK"
(obsolete, not for wine 4.0) 8. Check dotnet40 and vcrun2010, then click "OK"
8. Check dotnet452 and vcrun2010, then click "OK"
wait for install
9. Check "Run unistaller" and clikc "OK"
(obsolete, not for wine 4.0) uninstall all dotnet 4 apps and instances
uninstall all dotnet 452 apps and instances
10. Download dotnet 4.5.2 redistributable (offline version)
10'. Run winecfg and make sure Windows version is set to Windows 7 (because wine built-in dotnet installer switches this on Windows 2003)
11. Check "Run unistaller" and click "Install" button in that window, select new downloaded dotnet 4.5.2 installer
wait for the framework to install
12. Close all and restart the prefix
Run in terminal, under your user, not root,
WINEPREFIX="/virtuals/b4x" wineboot --restart
13. Also by using "Install" button in the window that appears when you select "Run uninstaller", install B4J
If you select "Launch B4J" the IDE should start.
14. Close the IDE
15. Same "Install" button - install JDK 8
16. Same procedure, install B4A
17. With winetricks, select "Change settings" and make sure you check:
glsl=enabled
ddr=gdi
videomemorysize=512 (don't know if really necessary)
orm=fbo
18. Close all
19. Go to your prefix folder, using a Linux terminal
cd /virtuals/b4x/drive_c/Program Files/Anywhere Software/Basic4Android and copy B4ASdkManager.jar to the directory where your java.exe was installed
20. Download android sdk-tools and unpack it manually in your prefix/drive_c/android-sdk directory, so you will have a "tools" directory under your prefix/drive_c/android-sdk
21. Go to the folder where your java.exe is and where you have copied B4ASdkManager
22. Run B4ASdkManager in a Linux terminal, with the command:
WINEPREFIX="/virtuals/b4x" wine ./java.exe -Xmx1G -Dprism.order=j2d -jar ./B4ASdKManager.jar
23. From the suggested installation things (already selected), deselect all lines referring to Intel x86 platforms and, also, all lines referring to Android emulator. Make sure you have at least 1G of free memory to allocate for java heap.
Some icons on some buttons are bigger than buttons, but, B4ASdkManager is still usable. On some points during the installation, it seems stalling, but, don't close it until it finishes (until the GUI becomes fully responsive again).
24. Close B4ASdkManager
25. Download latest android-tools for Linux and install them manually (I have simply copied adb to /usr/bin)
26. Check if adb is working
connect your android phone to the computer
Run in Linux terminal
adb devices
It must respond with something like:

List of devices attached
041c68157d25 device

if necessary, issue adb kill-server and adb -start-server, then, again, adb devices
27. Using a Linux terminal, go to
/virtuals/b4x/drive_c/Program Files/Anywhere Software/Basic4android
execute in terminal
WINEPREFIX="/virtuals/b4x" wine ./B4A.exe
Set the paths and configure your IDE upon your taste.
On compile & run, if you correctly installed adb, B4A will automatically detect it and upload your application.
If you have checked "Create icon on desktop" at installation stage, you will have a launcher on the desktop for B4J and B4A. At least on my Xubuntu 18.04 it works :)
Also, designer is fully functional, for both B4A and B4J.
Have fun with one of the greatest product, which is B4X suite :)

EDIT - tested and working with B4J 7.0
EDIT - tested and working with B4A 9.0
 
Last edited:

Mihai Rainer Jr.

Member
Licensed User
Step 1 states to use Wine 3.18 (1. Install last development version of Wine (3.18) - x86 version_ NOT Wine 4.0 stable i386.

There is still the problem with installing winetricks:
When I install winetricks from Ubuntu repos, it then brings in 3.0.1 versions of various Wine packages e.g. wine-stable. "wine --version" then shows wine-3.0. I think that this causes a problem when I try to install b4a.exe to run under Wine as running B4A gives an error window as in attached file. Is there a version of winetricks which will not cause the installation of these 3.0.1 wine packages?

Did not faced this issue. I have followed the exact above (edited) procedure after reinstalling my laptop.
More than that, today I have installed B4J 7.00 in another container, since I need it for GUI app development on Raspberry Pi (which, by the way, is working great with Liberica - JDK 11), using Raspbian Stretch Lite, without starting X server, because I need it for a kiosk project.
After adding winehq repository and installing wine 4.0 (stable), you may check the winetricks repository and dependencies with:
~#apt-cache showpkg winetricks
 

welu1805

Active Member
Licensed User
Longtime User
B4A V 8.80 as registered version now runs under my Linux! B4A Bridge runs too!

B4J V 7.00 runs too!

Great!

My configuration: Ubuntu 18.04 Mate 32 bit, wine 4.0, wine configured as Windows 7.
 

welu1805

Active Member
Licensed User
Longtime User
Now I tested B4A with a very large project. Main has about 10.000 lines and there are many classes and activities. It works fine!
 

stanks

Active Member
Licensed User
Longtime User
hello

i was successfull in first 10, but 11 is totally unclear to me. which uninstaller? in which window? which app? unclear 100% any help on that?
 

stanks

Active Member
Licensed User
Longtime User
jdk v8 for windows fails to install. i get error msg box with two squares in it :) (unicode?) you meant jdk windows version?
 

mplx

New Member
Licensed User
Great guide, thanks!

One thing to note: adb versions must be the same for linux and windows, otherwise the linux adb will be killed by the windows one...

adb server version (40) doesn't match this client (41); killing...
 

Mihai Rainer Jr.

Member
Licensed User
Great guide, thanks!

One thing to note: adb versions must be the same for linux and windows, otherwise the linux adb will be killed by the windows one...

Not necessarily. I am running B4J_bridge on Linux and connect IDE to localhost. Then, everything runs smoothly, and does not care about adb version difference. I am doing this, mainly because I am using applications with serial ports communication and it is not a straightforward task to add them to wine :)
 

Rinzwind

New Member
Licensed User
I tried to get B4j working in latest CrossOver under Catalina. It kind of starts, but theres some bad menu flashing every second or so. Those 3 tabs at the topright keep being hilited and also weird hilite stuff of current active code procedure name... :( Needed several tries from scratch to get it working and it wont start in one of the bottle templates that already include several libs and stuff.
 

fat32

Member
I have managed to follow the steps and install B4A in Lubuntu 18.10. Everything is working except when i try to connect the Designer to the app. Even if in the left-down corner says that is connected and the command "Restart ADB server" seems to work... the designer can't connect. It spits out this error msg:

Bash:
System.Exception: adb.exe F 02-16 14:20:10   138   139 sysdeps_win32.cpp:2678] _wenviron is not set, did you link with -municode?

I noticed that B4E, tries to find the adb.exe inside the "platform-tools" dir. My linux version of adb, works fine and finds the device connected. But the windows one, doesn't. Any ideas?
 

bjf

Member
Licensed User
Longtime User
I have managed to follow the steps and install B4A in Lubuntu 18.10. Everything is working except when i try to connect the Designer to the app. Even if in the left-down corner says that is connected and the command "Restart ADB server" seems to work... the designer can't connect. It spits out this error msg:

Bash:
System.Exception: adb.exe F 02-16 14:20:10   138   139 sysdeps_win32.cpp:2678] _wenviron is not set, did you link with -municode?

I noticed that B4E, tries to find the adb.exe inside the "platform-tools" dir. My linux version of adb, works fine and finds the device connected. But the windows one, doesn't. Any ideas?

I am sorry for posting in an old thread but this is EXACTLY the problem i'm faicing.
Did you manage to solve it?
 

Mihai Rainer Jr.

Member
Licensed User
I am sorry for posting in an old thread but this is EXACTLY the problem i'm faicing.
Did you manage to solve it?
Hi, I found that you need to use a specific adb version for Linux in order to work (1.0.40) 1.0.39 fails, 1.0.41 fails, too (Linux adb server is crashing when the adb.exe is trying to connect in order to upload the app to the mobile terminal). Hope this helps :)
 

bjf

Member
Licensed User
Longtime User
Hi, I found that you need to use a specific adb version for Linux in order to work (1.0.40) 1.0.39 fails, 1.0.41 fails, too (Linux adb server is crashing when the adb.exe is trying to connect in order to upload the app to the mobile terminal). Hope this helps :)

Thank you for answering, really appreciate it!

However this did not fix my issue :(
Do you think the windows adb-version also has to be 1.0.40?
 

johnaaronrose

Active Member
Licensed User
Longtime User
@Mihai Rainer Jr.
You mentioned installing SDK Manager. My guess is that it is required to create emulator "images". Even after installing it, running SDK Manager or AVD Manager from B4A menus only brings up a blank screen titled SDK Manager. Any ideas?
I would like to do that as I'm not impressed by B4A-Bridge which can be a little hit & miss as well as the nuisance of going through answering requests about installing the app (e.g. Play Protect objecting even though I've amended my phone's Android Settings to "Allow installation from unknown sources"). I've also noticed that installing the app allowing overwrite of the existing app on the phone can lead to an unusable app on the phone. IMO B4A should really allow automatic downloading & installation of the app by usb cable: you can do it manually using Terminal but that's a nuisance.
Reviving an old app of mine has lead to a problem with synchronously calling (using library Okhttputils2) code to download a database from the internet. Erel advised putting the code in a Service Module or using B4XPages: to me B4XPages seems the better option as I want a progress bar (on the calling layout's module) updated as the database is downloaded. I haven't been able to find much documentation on converting to B4XPages except for a youtube video which is about creating a B4XPages app from scratch. The youtube video is at
Any ideas?
 
Last edited:

Mihai Rainer Jr.

Member
Licensed User
@Mihai Rainer Jr.
You mentioned installing SDK Manager. My guess is that it is required to create emulator "images" since clicking "AVD Manager" in B4A does nothing. Is that correct?
I would like to do that as I'm not impressed by B4A-Bridge which can be a little hit & miss as well as the nuisance of going through answering requests about installing the app (e.g. Play Protect objecting even though I've amended my phone's Android Settings to "Allow installation from unknown sources"). I've also noticed that installing the app allowing overwrite of the existing app on the phone can lead to an unusable app on the phone. IMO B4A should really allow automatic downloading & installation of the app by usb cable: you can do it manually using Terminal but that's a nuisance.
Reviving an old app of mine has lead to a problem with synchronously calling (using library Okhttputils2) code to download a database from the internet. Erel advised putting the code in a Service Module or using B4XPages: to me B4XPages seems the better option as I want a progress bar (on the calling layout's module) updated as the database is downloaded. I haven't been able to fing much documentation on converting to B4XPages except for a youtube video at which is about creating a B4XPages app from scratch rather than converting an existing app to B4XPages. Any ideas?
I cannot help you about AVD, since I'm only using physical devices. You need to install adb for Linux in order to be able to deploy the application directly to your device. It is working on my side with even multiple devices simultaneously connected, when de IDE is asking to select the target. Recently I found that I don't even need to use a cable and I'm using adb to connect over WiFi or Ethernet (I'm working with some industrial Android tablets that have also Ethernet interface). If the device is not connecting over the LAN/WiFi with adb, after power-up I'm connecting over the USB and issuing the command
adb network activation:
adb -s <device_id> tcpip 5555
Then everything is working just fine over the network (a little slower over WiFi, obviously, but enough for me). This way I'm able to use the USB host on the tablet or OTG host on the phone to connect various electronic boards to use them for serial communication. No USB cable needed or terminal required for application upload. The only issue I found is that you need to install the Linux adb version that matches the version installed in wine compatibility layer.
For the other issues, I'm afraid I cannot help you, since I was never there (converting to B4XPages).
 

johnaaronrose

Active Member
Licensed User
Longtime User
After I installed B4A & B4Jfollowing the instructions at https://www.b4x.com/android/forum/t...x-mint-20-2-cinnamon-with-64-bit-wine.134069/ which uses later version of some software (e.g. r30 of platform-tools) and initially worked Ok for B4A Compile&Run. 'm now getting a strange message in B4A when trying to install to my phone.
B4X:
adb.exe F 02-25 09:42:27   288   285 sysdeps_win32.cpp:2743] _wenviron is not set, did you link with -municode?
Somebody on thread at https://www.b4x.com/android/forum/t...on-with-b4a-bridge-nor-with-usb-cable.136501/ has had the same problem but no solution was posted. Have you ever seen that?
Another interesting point is that whichever version of Linux adb I use in Terminal, it never shows my phone or tablet for ''adb devices' when connected by USB cable. But Ubuntu 20.04 sees my phone or tablet in my 'dock' when I connect it by USB. When I did the install, I followed this step below from walt61:
adb must be version 1.0.40 for both Windows (for Wine) and Linux (platform tools 28.0.2); you can check this with
adb version
You can download both versions in one zip file from
https://www.dropbox.com/sh/a45a6ym8l1ue5fk/AAB-7ocL5O4kSvT7cChZB5LEa?dl=0 (thank you @EnriqueGonzalez https://www.b4x.com/android/forum/members/enriquegonzalez.82999/). In a step further on, it is explained what to do with the downloaded file: namely:
Copy Linux adb1.0.40 (platform-tools_r28.0.2-linux.zip) you downloaded in step 19 from the Dropbox link to /home/YOUR_USER_NAME/B4X/platform-tools
PS in an earlier post, you said that you linked from the IDE to localhost. Could you clarify that?
 
Last edited:
Top