Android Tutorial Super-fast alternative to emulator -> x86 Android

Hi all

*EDIT3*

For a much easier to set up and faster Android emulation please now look at this thread:

GeanyMotion
http://www.b4x.com/android/forum/threads/android-emulation-super-fast-speed.30586/

*********************************


*EDIT2* Have a look at AndroVM which should make the whole "Android on a PC" process easier to set up.
(Credit to Drowles for finding this)
I recommend the new method which is a lot less hassle than the old method below

I am enjoying B4A even more so now after installing a super-fast Android on my Windows PC. The install is actually a virtual Android (Froyo/GingerBread/Icecream Sandwich) and is MUCH faster than the emulator!

androidvm_ICS.png




NEW METHOD - Quick steps
1. Install Virtual Box
2. Download one of VM's (OVA files) from AndroVM's download page
3. Double-click the OVA which should start Virtual Box and import it. If not, import the OVA from within Virtual Box File menu>Import
4. BEFORE running the VM, change the following under Settings > Network:
Change [Adapter1] Attached to = Host-only Adpater
Change [Adapter2] Attached to = Bridged Adpater then select your Ethernet adapter card under Name​
5. Click Apply
6. Double-click the androVM_vbox86x_xxx to start the Android VM

7. From the Android VM launch the AndroVM Configuration app to find out the IP settings
8. Go to Settings > {} Developer Options. Enable the option. Enable USB debugging
9. Establish a connection via Androids ADB. Tip: It it easier to create *.BAT file with the following script, changing path/IP settings to accordingly):
d:
cd ..
cd android
cd platform-tools
adb connect 192.168.56.102
adb devices
pause
exit

If all is well B4a should be able to compile and send the app straight to the running Android VM

Windows keys and their Android actions (Ice cream Sandwich)
================================================
Android BACK key ---> Escape key
Android HOME key ---> Home key
Android MENU key ---> F1 or F10
Android POWER button ---> End key

Right Control = Default HOST key (break out of virtual Android)

************************


Old Method

INSTALLATION
======================================
First of all, follow this excellent guide for setting up and installing

How to install Android x86 2.2 (with Virtual Box)

At STEP 5 you can go straight for the Live CD option for initial testing


BEFORE LAUNCHING THE VIRTUAL ANDROID
=========================================
set the VirtualBox machine's network mode (under Settings > Network) to Bridged Adapter and accept the defaults. Your PC and emulated PC will now have IP addresses in the same range

Double-Click the virtual Android entry to launch the virtual x86 Android
Once the emulator is running, press Alt + F1
Type netcfg then note the IP address ** (usually starting with 192.168.x.xxx)
Return to the emulator by pressing Alt + F7

Getting B4A to communicate with Android
======================================
Open the Windows command prompt (Start > Run > CMD)
Navigate to wherever Android\platform-tools folder is
Type adb connect 192.168.x.xxx (the address noted at ** above)

Try compiling a B4A project. If everything is good your app/game should appear (very quickly) in the virtual Android

TIP -- You can create a *.bat file to aid in establishing the connection. This is something you can simply double-click to carry out command line instructions. My own "Android-Connect.bat" file contains the following (change path/IP settings to suit):
d:
cd ..
cd android
cd platform-tools
adb connect 192.168.56.102
adb devices
pause
exit

Happy coding, and enjoy WARP SPEED!

Windows keys and their Android actions
==============================
Android BACK key ---> Escape key (also can use right-mouse button in Froyo/GingerBread)
Android HOME key ---> Home key (also can use Windows Key in Froyo/GingerBread)
Android MENU key ---> Menu key (Froyo/GingerBread)
Android POWER button ---> End key

Right Control = Default HOST key (break out of virtual Android)
 
Last edited:

rbsoft

Active Member
Licensed User
Longtime User
Thank you for that one, Jim. Works very fast!

nfordbscndrd - B4A communicates without problems via B4A-Bridge.

Rolf
 

nfordbscndrd

Well-Known Member
Licensed User
Longtime User
B4A communicates without problems via B4A-Bridge.

Thanks. I just tried it and see that it becomes just another device in the list to install to.

However, the compile was done, I got a Basic4android error saying

An error occurred.
Cannot forward debug port:
error: unknown host service.

Does this mean that B4A Debugger will not work with it?

Also, the VirtualBox window says "(No service)" on the "security screen" and when I try to move the unlock icon up, the cursor disappears.
 

NJDude

Expert
Licensed User
Longtime User
Just sharing a little experience, I tried that a while ago and works fine, but sometimes when you reboot you'll get a black screen and a solitary message saying ERROR and that's it. you will have to re-install/recreate the VM.

I'd rather invest on a cheap tablet, just my 2 cents.
 

hackhack

Active Member
Licensed User
Longtime User
Just sharing a little experience, I tried that a while ago and works fine, but sometimes when you reboot you'll get a black screen and a solitary message saying ERROR and that's it. you will have to re-install/recreate the VM.

I'd rather invest on a cheap tablet, just my 2 cents.

Can't you make a copy of the image when you set up the machine? Then just copy it over the active image?
 

Jim Brown

Active Member
Licensed User
Longtime User
Regarding the cursor control, you will need to disable mouse integration by clicking into the window and pressing RightCtrl + I. You should then see a black Linux cursor

ADDITIONAL NOTES:
===============
Designer
I cannot get the designer to work with the virtual Android. Whilst the Designer app shows up there appears to be no 'two-way' communication going on. B4A says "unknown host device"
Erel, would you be able to offer any assistance here?

Orientation
There appears to be no way to orientate the device once up and running
What I found is, applications that are designed to run in Landscape are somewhat slow. Choosing b4A's Orientation =Both speeds things up
UPDATE: See post below regarding setting up a portrait screen
 
Last edited:

Jim Brown

Active Member
Licensed User
Longtime User
Hi Erel
I have attached the log report which may help. The specific error message is:

error: unknown host service​
Restarting ADB Server may solve this problem​



HOW TO CREATE A PORTRAIT SCREEN
=====================================
This one is quite involving but here is how I managed to get a portrait screen set up (as 480x800):

1) Close any virtual Android that may be running. It must be powered off instead of using the snapshot option
2) Open Windows command prompt (Start > Run > CMD)
3) Navigate to where VirtualBox is installed
4) Type VBoxManage setextradata "NameOfYourAndroidVM" "CustomVideoMode1" "480x800x16"

* The NameOfYourAndroidVM is as shown in the VirtualBox list. For example, I called mine "Android x86 2.2"

vbox_name.png


5) Run your VM Android from the VirtualBox
6) Move cursor to Live CD - VESA mode then press TAB
7) Edit the line and change the vga=788 to vga=999
8) You should get an error message. Press ENTER to see a list of display options
9) Enter the code for your 'portrait' screen setting. Mine came up under mode value 360:
vbox_video.png



The boot sequence should now kick off. If all goes to plan you get a nice portrait layout
TIP: Press MENU key (Windows Menu key) to quickly unlock the screen

x86AndroidP2.png
 

Attachments

  • B4A_Designer_Androidx86.zip
    12.5 KB · Views: 717
Last edited:

pappicio

Active Member
Licensed User
Longtime User
wow, very interesting, and works reaaly well....
only 2 questions:
1) I cannot find portrait mode, so all apps runs usually in 90 degrees turned respect my monitor or virtual-android;
2) I usually use sd-card to store databases, and it cannot find an sd-card, and cannot test my apps (usually, at start, if my app cannot see an sd-card, amessage is showen about, and then it closes itselfs!)

thanks a lot!
 

Jim Brown

Active Member
Licensed User
Longtime User
1) I cannot find portrait mode, so all apps runs usually in 90 degrees turned respect my monitor or virtual-android
I have written some instructions in the previous page regarding portrait mode

2) I usually use sd-card to store databases, and it cannot find an sd-card, and cannot test my apps
The Android VM can apparently detect real USB and SDCards when inserted. Try inserting a physical USB/SDCard into the PC then right-clicking on this option. Select your card/stick to mount

vbox_SDCardUSB.png


Although my USB device is available it does not appear to be visible to the Android system (that is, no scanning takes place). Still experimenting ...
 

pappicio

Active Member
Licensed User
Longtime User
I have written some instructions in the previous page regarding portrait mode

The Android VM can apparently detect real USB and SDCards when inserted. Try inserting a physical USB/SDCard into the PC then right-clicking on this option. Select your card/stick to mount

vbox_SDCardUSB.png


Although my USB device is available it does not appear to be visible to the Android system (that is, no scanning takes place). Still experimenting ...

thanks for usb, but for screen resolution, nothing to do, I've yet readed the tute about, maybe my video-card doesn't support that kind of resolution!
 

Jim Brown

Active Member
Licensed User
Longtime User
The good news is, the designer communicates successfully via the B4A Bridge app. Nice

I must say, this new VM method is a joy:
+ Being able to save state and resume,
+ Having the option to pause the whole system
+ Resizing the whole window (in Scale mode)
+ Speed!

The only real gotcha is not being able to rotate the display. My workaround here is to have two VM's set up, one with portrait and the other with landscape resolution
 

pappicio

Active Member
Licensed User
Longtime User
The good news is, the designer communicates successfully via the B4A Bridge app. Nice

I must say, this new VM method is a joy:
+ Being able to save state and resume,
+ Having the option to pause the whole system
+ Resizing the whole window (in Scale mode)
+ Speed!

The only real gotcha is not being able to rotate the display. My workaround here is to have two VM's set up, one with portrait and the other with landscape resolution

into VM screen options, you can choice 1 or more screen, when sistem starts, you will see 2 or more screens if setted on 2 or more, but I don't know if you can set one into lndscape mode and other into portrait one.
 

Jim Brown

Active Member
Licensed User
Longtime User
into VM screen options, you can choice 1 or more screen
That creates a running Android VM and a separate blank window from my testing. I don't believe the Android build supports dual screens

However, you can have a portrait and landscape VM running at the same time. What I did is clone the first VM (using 're-initialize MAC address' and 'Linked' options) then have both running together

After that I used adb connect xxx.xxx for BOTH unique MAC addresses of the Android VM's. Now, when I run a B4A project I get the option to choose whichever target I want
 

Darkwoof

New Member
Licensed User
Longtime User
Hi all

I am enjoying B4A even more so now after installing a super-fast Android on my Windows PC. The install is actually a virtual Android (Froyo 2.2 build) and is MUCH faster than the emulator!

x86Android.png


INSTALLATION
======================================
First of all, follow this excellent guide for setting up and installing

How to install Android x86 2.2 (with Virtual Box)

At STEP 5 you can go straight for the Live CD option for initial testing


BEFORE LAUNCHING THE VIRTUAL ANDROID
=========================================
set the VirtualBox machine's network mode (under Settings > Network) to Bridged Adapter and accept the defaults. Your PC and emulated PC will now have IP addresses in the same range

Double-Click the virtual Android entry to launch the virtual x86 Android
Once the emulator is running, press Alt + F1
Type netcfg then note the IP address ** (usually starting with 192.168.x.xxx)
Return to the emulator by pressing Alt + F7

Getting B4A to communicate with Android
======================================
Open the Windows command prompt (Start > Run > CMD)
Navigate to wherever Android\platform-tools folder is
Type adb connect 192.168.x.xxx (the address noted at ** above)

Try compiling a B4A project. If everything is good your app/game should appear (very quickly) in the virtual Android

Happy coding, and enjoy WARP SPEED!


Windows keys and their Android actions
==============================
Escape key (or right-mouse button) = Android BACK key
HOME or Windows Key = Android HOME key
MENU key or middle mouse button = Android MENU key
END = Android POWER button
Right Control = Default HOST key (break out of virtual Android)

Ahhh~! Why hadn't this occurred to me earlier? Off to try this with VMWare Workstation, should probably work similarly!

Thanks man! :sign0142:
 

nad

Active Member
Licensed User
Longtime User
:sign0142:

One question Jim. How can we change the resolution with VESA when using the vhd version?

Wonderful job! it really goes fast.
 
Top