Use Androidx86 with VirtualBox as an emulator for AI2

Update (2023-10-31): there is currently an issue loading a project that contains assets, or when trying to add an asset to an asset-less project running in companion. Will advise if it gets resolved.

This guide aims to show you how you can use Androidx86 as an emulator for AppInventor AI2. Androidx86 is currently running Android 9, but they are working on stable versions of Android 10+) I will not go into the full details of setting up VirtualBox or how to install Androidx86 from an iso to a virtual machine, this information is available elsewhere.

I carried out the installation and setup on Xubuntu 22.04 LTS, but this should also be possible on Microsoft Windows and Apple Macintosh

BASIC SETUP
Download the Androidx86 iso
I used this one, current stable at time of writing.

Install / Setup VirtualBox
Create new 64 bit (Ubuntu) Virtual Machine (VM)
I called my VM "Androidx86"
Load the Androidx86 iso
Install Androidx86 to the VM
Close
Remove the loaded iso
Boot up your Androidx86 VM, you should get a tablet sized Android interface

ANDROIDx86 SETTINGS
Find a display setting that works for you, for me 540x960x32 works well enough for my needs.
Fix the display setting - follow one or both of the two links below to see how
https://www.youtube.com/watch?v=VHwOyrWodS4
https://4sysops.com/archives/change-the-screen-resolution-of-an-android-virtualbox-vm/

On the Androidx86 VM, download and install the AI2 x86 Emulator from here (this is the direct link from MIT):
http://ai2.appinventor.mit.edu.ezproxy.canberra.edu.au/companions/Emulator.apk

Give Companion App: Storage (read/write) permissions in App Settings

You may need to play with the wifi settings to get it working correctly:
image

Set the emulator Date/Time to match your local Date/Time, otherwise you get USA EST.

VIRTUALBOX SETTINGS
Edit the vbox file with required extras...you can/should do this using the VBoxManage (.exe) command when the VM is closed

for example:
VBoxManage setextradata "Androidx86" "CustomVideoMode3" "540x960x32"

  <ExtraDataItem name="CustomVideoMode3" value="540x960x32"/>

Prevent stupid sidebars from showing in VM
How to disable notification panel on the right? V. 7.0.2 - virtualbox.org
You can do this with VBoxManage commands when VM is not running
VBoxManage setextradata global GUI/SuppressMessages confirmGoingFullscreen,remindAboutMouseIntegration,remindAboutAutoCapture

  <ExtraDataItem name="GUI/SuppressMessages" value="confirmGoingFullscreen,remindAboutMouseIntegration,remindAboutAutoCapture"/>

Untick Menu and Status Bars - to provide a cleaner interface
Set Network Adapter to Bridged
Drag and Drop not working for me, YMMV
Set up the integrated mouse control

If you wish, you can change the icon that your VM uses:

VBoxManage modifyvm Androidx86 --iconfile "/home/user/Pictures/myimage150.png"

HOST
Create a bash script to load the VM (you will need something different for MS Win / Mac). This starts the VM and positions it on my second screen. It also renames the window title :wink:

#!/bin/bash
##start androidx86 emulator and rename
##to find vms run: VBoxManage list vms

##starts androidx86 emulator
VBoxManage startvm "Androidx86" &
sleep 12
##sets window position
wmctrl -r "Androidx86 [Running]" -e 0,1363,69,540,960
## changes title
wmctrl -r "Androidx86 [Running]" -N "Androidx86 - TIMAI2 - AppInventor"

When all that is done, you should be able to connect AI2 to your emulator:
Check that your virtual device is on the same subnet
Make sure you always tick the Legacy box

NOTES

  • The VM takes @ 30 seconds to boot up on my system
  • You will find that resetting the connection to the companion app does not close the companion app, you will have to do this manually (this was the same with genymotion), this is made easier if device default theme is used.
  • To run an app in Landscape, you will need to add another extra value e.g. 960x540x32, and select this from grub when you run the VM.
  • With use, I have found that if I leave the VM open for a few hours, without using it, the mouse goes AWOL, and I have to reboot/restart the VM
  • If, instead of Powering Off, save the VM state, loading up the VM then only takes a few seconds, and you are ready to go.

If I get time or so inclined, I might modify the Androidx86 iso to incorporate some of these settings.

1 Like

Hmm. If you try mkdir'ing /storage/emulated/0/Android/data/edu.mit.appinventor.aicompanion3/files/AppInventor/databases/ via adb, does that solve the issue (assuming the folder doesn't exist)?

The databases folder is already there, and it contains hashTable.db :frowning:

Hello Tim - @TIMAI2

I write you for clues for a problem related to your post.

I was thinking in make a tutorial for installing an Android x86 in the pc and use it for developing app in a more direct way, without an emulator, but you already do it. Good for you.
Well I my path i found a lot of versions of android for the pc like the Android x86 from the original project, FydeOS, PhoenixOs, PrimeOS, BlissOS.

Everyone gives me a headache and ended installing PrimeOS after a lot of problems.
BUT... When all was right, i couldn't make any screenshot.
I try it from LiveCD version (without an account) and also installing it to the hard disk (with a google account).

I found that was blocked from the start.
I search in all the environment, try with developers options, install a screenshot app (also get blocked by the system.
DO you have any clue?
I can share with you the pc configuration, but is not the problem. Is something in the installation.
I think (MAYBE) the problem is the version i have installed.
I search in XDA forum (none of the solutions worked), also the half of the solutions of youtube are not solutions at all, are videos about the system, captured from an external way.
Prime Os doesn't have any forum for asking about this, that's the reason of asking THAT HERE, and asking you for the obvious reason, you have made the same path i am trying to do.
...
Maybe is a small thing i am missing... Maybe not.
Well. In advance i give you my thanks for any help you can provide me.

I looked at and considered all of these, but went back to the mothership (Androidx86) for my working solution.

I generally use my computer to screenshot the emulator.

Also, not using it at the moment, because Genymotion and AI2 have "come together" in recent times.

1 Like