Android Question Newbie: Can't run B4A app in emulator

Widget

Well-Known Member
Licensed User
Longtime User
It's been almost 5 years since I used B4A so I decided to download the most recent eval and have a go.
I have the Android Emulator using HW Acceleration. I'm using Win7 and running as Administrator user.

Everything installed fine, but when I try to compile and run an app in the Android Emulator by pressing F5, I get:

B4A version: 5.80
Parsing code. (0.00s)
Compiling code. (0.25s)
Compiling layouts code. (0.00s)
Generating R file. (1.33s)
Compiling debugger engine code. (2.94s)
Compiling generated Java code. (0.84s)
Convert byte code - optimized dex. (0.36s)
Packaging files. (0.18s)
Trial version-skipping library resources (0.00s)
Signing package file (debug key). (0.45s)
ZipAlign file. (0.18s)
Installing file to device. Error
Cannot create process: Access is denied. (5)
* failed to start daemon *
error: cannot connect to daemon

And of course the app does NOT get sent to the emulator.

Then I tried GenyMotion and altered its adb.exe location so it used the Android SDK version instead of its own. When I try and run the B4A app I get the same error message. This B4A app is a simple one line MsgBox(). Of course it uses no libraries. ADB.EXE is running and I've confirmed it is the Android SDK version using Process Explorer.

It appears to me to be a security problem. Can someone confirm? I am running B4A and GenyMotion as Admin and I modified the properties of ADB.EXE as "Run this program as an administrator".

Still no joy.

Any ideas?
(I lent my Android device to someone else and I don't have one available at the moment. I should be able to get something to appear in the Emulator, shouldn't I? The emulator worked just fine for me 5 years ago with B4A. )

TIA
Widget
 

Widget

Well-Known Member
Licensed User
Longtime User
Did you try Tools - Restart ADB server ?
Yes, several times. Even rebooting and re-installing B4A didn't solve the problem.

Does anyone have the emulator working in Win7 (or later)? If so, is there a trick to it? I did utter a few words under my breath when I pressed F5,
but it wasn't "hocus pocus". :)
 
Upvote 0

Widget

Well-Known Member
Licensed User
Longtime User
The emulator works on all versions of Windows. However the emulator is slow and unreliable and you shouldn't waste your time trying to get it working. Either use a VM such as genymotion or use a real device.

I tried GenyMotion and it will not connect with that as well. It gives me the same error. The question is why?
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
As to the emulator issue not working, it should work fine even on Windows 7. As @KMatle said, myabe it is an Antivirus and Firewall issue and which may be blocking adb. Try to turn them off.

PS: I am very happy with the latest android-emulators (with hardware acceleration -x86 - enabled). They run fine and fast and are much improved.
 
Upvote 0

Widget

Well-Known Member
Licensed User
Longtime User
As to the emulator issue not working, it should work fine even on Windows 7. As @KMatle said, myabe it is an Antivirus and Firewall issue and which may be blocking adb. Try to turn them off.

PS: I am very happy with the latest android-emulators (with hardware acceleration -x86 - enabled). They run fine and fast and are much improved.

I should have mentioned yesterday I and deactivated the AV and Firewall and it did not make a difference.
I had also installed the Intel Hardware Accelerated Execution Manager (HAXM) for the standard Android emulator but of course that did not make a difference.
I installed GenyMotion and that did not make a difference.
Re-installing B4A and Android SDK did not solve the problem.
I elevated the security for adb.exe, b4a and even the emulator.
Today I created a virtual box (Win7) and started all over again, installing Java, Android SDK and B4A. I see installing the Android SDK is as fast as ever. ;-)

B4A simply would not connect to the emulator, regardless of what emulator I was using.

But I found out what the problem was. I was using the install instructions at www.b4x.com/b4a.html.
I thought since it was on the b4x website it would be the most up to date reference for installing the software.
Well, I was wrong.

I should have been reading the B4ABeginnersGuidev3_2.pdf where it clearly states:

Installation instructions:
The first step should be to install the Java JDK, as Android SDK requires it as well.
Note that there is no problem with having several versions of Java installed on the same computer.

- Open the Java 8 JDK download link.
- Check the Accept License Agreement radio button.
- Select "Windows x86" in the platforms list (for 64 bit machines as well).
Android SDK doesn't work with Java 64bit JDK.
You should install the regular JDK for 64-bit computers as well.

Since I have Win 7 64bit, I had naturally installed the 64 bit version of Java. And the PDF file explicitly states the Android SDK does not work with Java 64bit. So I installed Java for Windows x86 (32bit) and presto-chango, B4A can now communicate with the emulator.

The web page at www.b4x.com/b4a.html doesn't mention to use only the 32bit Java version. In fact, in the previous section for remote compilation, it said to download either 32bit/64bit version of Java. So naturally I thought this applied to Local Compilation as well.

I'm only reporting this in hopes it may eliminate someone else spending a day trying to solve the same problem.

I wonder if the pubs are open yet? Who's buying??
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
Glad you resolved it.
I just had a beer while watching the football game on telly...
 
Upvote 0

Widget

Well-Known Member
Licensed User
Longtime User
I have more info as to why the B4A was not communicating with the Android emulator.

When I run B4A and click on "Tools" > "Restart ADB Server", B4A issues the command:
"C:\Android\tools\..\platform-tools\adb.exe" kill-server

but never executes the "adb.exe start-server" command. (I used ProcMon to monitor the files that B4A is accessing.)

The only way I can get B4A to use the emulator is if I execute "ADB.EXE Start-Server" manually (from a DOS window or batch file.) Then adb.exe shows up in the process explorer and pressing F5 in B4A will send the app to the emulator without any problems. (It is quite fast too with HAXM hardware acceleration with "Intel Atom (x86)" CPU, takes about 1 second to load a small B4A app).

With ADB.EXE running, if I then execute Tools > Restart ADB Server from B4A, it kills off the ADB.exe task and never restarts it. So it appears to me B4A is missing the "adb.exe Start-Server" command.

BTW, the Android SDK has to be installed at the root of C: if ADB.exe is to install properly. I could not get it to run if the Android SDK is installed on Drive D: (even without the space in the directory name).

Hopefully this helps someone down the road.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
BTW, the Android SDK has to be installed at the root of C:
For me it is installed in E:\Android\android-sdk and works fine here.
But i DONT use the Android-Emulator at all! I always use a real device
 
Upvote 0

Widget

Well-Known Member
Licensed User
Longtime User
For me it is installed in E:\Android\android-sdk and works fine here.
But i DONT use the Android-Emulator at all! I always use a real device

That's because you're not using adb.exe.
If you have time, try running e:\Android\Android-sdk\platform-tools\adb.exe and see if it is visible in the task manager. On my machine it won't run from drive d: because of UAC restrictions.

(I assume you are using Win7 or later. Windows XP does not have a problem.)
 
Upvote 0
Top