English only (for the moment…)
How to install Android Studio and VirtualBox on a VMware virtual machine running Ubuntu 16 64 bit.
Policy and Agreement
Reading this text the reader accepts the following agreement rules:
The present text is intended to represent a guide for personal or professional use,
all the instructions and commands are intended to be only suggestions based on personal experience.
None of the present istructions is provided with any kind of warranty.
The author and the publisher can never be responsible for any kind of damage or issue derived by or caused by or attributed to any usage of the present text.
This set of instructions is only and exclusively intended as a friendly guide for those who want to use Virtual Machines and Open Source software for Software Development purposes.
This guide is intended for people who are not totally confident with these kind of systems,
the language used want to be simple to encourage more people in approaching the
wonderful world of Linux OS and SW Development.
Help, suggestions and guidelines are available on:
https://askubuntu.com/
https://linuxconfig.org
https://stackoverflow.com
Requisites:
PC Windows 7 64 bit or 10 64 bit, VT-X Enabled, CPU at least i3 or equivalent,
at least 6GB or RAM memory, at least 80GB of free hard disk space.
Convention: the commands executed inside the Ubuntu guest OS Terminal begin with the char # to be easily identified.
————————- BEGIN ————————-
Install VMware Workstation free evaluation version
https://www.vmware.com/products/workstation-player/workstation-player-evaluation.html
Download Ubuntu 16.04.05 64 bit OS ISO
http://old-releases.ubuntu.com/releases/16.04.5/
http://old-releases.ubuntu.com/releases/16.04.5/ubuntu-16.04.5-desktop-amd64.iso
Install Ubuntu 16.04.05 64 bit as guest OS with very basic settings, remembering that this guide is for who want to learn and explore Linux and virtualization.
Prepare the virtual machine guest system as described in the following steps:
Create a new Virtual Machine
I will install the operating system later
choose Linux, Ubuntu 64bit
insert a name for the VM
Maximum disk space 60 GB (at least) & Store virtual disk as a single file
Finish
Click “Edit virtual machine settings” and set at least the following virtual hardware settings:
Memory 3072 MB (3GB)
Processors 1, Processor cores 2 (or Processors 2)
Hard disk SCSI 60GB
CD/DVD use image file (ubuntu-16.04.5-desktop-amd64.iso)
USB Controller present (bluetooth may be disabled)
Sound Card Auto detect
Network Adapter NAT (or Bridged in alternative)
Display Auto detect
Start the Virtual Machine
At the first screen select your language in the left panel and click “Install Ubuntu” to begin the install process and choose the following buttons
Continue
Install now
Continue
select your timezone – Continue
select your keyboard layout, test it – Continue
insert the username, computer’s name and password – Continue
At the “Installation Complete” message click Restart Now
Press enter
From the VMware menu click Player – Removable Devices – CD/DVD – Settings
change the selection to Use physical drive and press OK
Welcome to Ubuntu – insert your password to login
Tuning of Ubuntu OS
Enter your password every time it will be required to let the System process your requests.
Please note that the following steps are intended as suggestions,
based on personal taste and they are absolutely not mandatory.
Feel free to customize your Ubuntu as you prefer and even to skip to step n. 6.
Choose Don’t Upgrade and press OK to confirm
Open the Settings using the icon on the left sidebar :
Displays
Set a convenient Screen Resolution
Sticky edges = off
Appearance
Background = solid color
Behavior = Show the menus in the window’s title bar
Menus visibility = Always displayed
Brightness & Lock
Turn off = never
Lock = off
Security and privacy
Record application usage = off
Generally for more privacy set all options to off in the tabs of this privacy settings
Network
Wired – Options – IPV6 = ignore
Software and Updates
Ubuntu Sw – unflag Proprietary drivers, Software restricted
Other SW – unflag Independent, Independent source code
Updates – unflag Pre-released, unsupported
Automatically check = never
Notify new versions = never
Refresh and close without updating
Firefox hint:
Set your homepage to https://start.duckduckgo.com/ and choose Duckduckgo as default search engine
Why? Because it’s the search engine that doesn’t track you.
Find more information at: https://duckduckgo.com/spread
Shut down the VM, set the CD/DVD to use physical drive/autodetect, turn on the VM.
Open the Terminal and let it become your friend
conveniently lock the Terminal to the launcher (right click option)
From the Terminal menu – Edit – Profile Preferences – Colors – choose your preferred color scheme then click Close
those instructions are not mandatory but could be useful for a better knowledge of the system you are going to use.
Note about the Linux shell (Bash) and how to use the commands:
for a list of options (flags) of a Terminal command, simply type the command followed by –help
you will be shown useful information about it (examples: ls — help , ip –help , unzip –help)
In the terminal type and enter:
# ip a
take note of the IP address (inet 192.168.x.x/24) the IP 192.168.x.x will be used to connect to your VM from your Host System
Important: what about the ROOT?
In Linux (and Unix in general), there is a SuperUser named root.
https://help.ubuntu.com/community/RootSudo
Example: in the terminal type and enter:
# sudo ls
this command requires your password because it begins with “sudo” that stands for SuperUserDo instruction
from now on the password could be asked every time we use the powerful “sudo” formula
ls shows the contents of the directory where we are, for more commands see :
https://linuxconfig.org/linux-commands
https://www.tecmint.com/linux-commands-cheat-sheet/
https://ss64.com/bash/
https://www.linux.com/learn/how-use-linux-command-line-basics-cli
http://www.linuxcommand.org/
Updates time
in the Terminal execute sudo apt-get update -y && sudo apt-get upgrade -y Wait until all tasks are completed when the Terminal will turn back to the prompt for commands
Open the Search menu using the first icon in the left sidebar type update, open the Software Updater and run it
Open the Settings menu, click Language support and install the suggested updates
Perform a reboot.
From now on every # is followed by a command or list of command to be typed and entered in the Terminal
Disable IPv6
# sudo vi /etc/sysctl.conf
Append the following lines, with a comment before them like “ # Disable IPv6” without quotes
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
net.ipv6.conf.ens33.disable_ipv6 = 1
To load the configuraton run the command
# sudo sysctl -p
Disable Firewall
# sudo ufw status
# sudo ufw disable
Updates and cleaning operations
# sudo spt-get clean && sudo apt-get autoclean && sudo apt-get autoremove all
# sudo apt-get update -y && sudo apt-get upgrade -y
Install Java 8 Platform by Oracle
# sudo add-apt-repository ppa:webupd8team/java
# sudo apt-get update
# sudo apt-get install oracle-java8-installer
Confirm if you want to install Java software and if you accept the license to proceed.
# sudo apt-get install oracle-java8-set-default
Check that the correct Java version is in use (now or in the future)
Platform check
# java -version
will return something like
java version “1.8.0_201”
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)
Compiler check
# javac -version
will return something like
javac 1.8.0_201
Alternatives check
# sudo update-alternatives –config java
This command is useful when more Java platforms are installed, since our installation is a fresh new one,
simply press enter to confirm the default selection
Libraries and Dependencies
Android Studio might require some 32-bit libraries and since the Ubuntu OS is a 64-bit system, this requirement could be satisfied executing the following commands in the terminal: sudo dpkg –add-architecture i386 sudo apt-get update sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386 lib32z1 libbz2-1.0:i386
Get and install Android Studio
https://developer.android.com/studio/ #downloads
The version 3.3.1 is available at the moment of this guide being written,
choose and download:
android-studio-ide-182.5264788-linux.zip cd Downloads unzip -d /opt android-studio-ide-182.5264788-linux.zip wait the extraction to be completed
(the -d switch extract the ZIP file contents in a chosen directory, “/opt” in our case) cd /opt/android-studio/bin ./studio.sh
Create a link to run Android Studio typyng “studio” from any folder
# sudo ln -s /opt/android-studio/bin/studio.sh /usr/local/bin/studio
Run Android Studio
# studio
choose “Do not import settings”
choose if data could be shared or not
Proceed with the install procedure:
Custom – IntelliJ – Next -Next -Finish
Since we are using a VM I do not suggest to install VDI (Virtual Android Devices)
since they require VT-X to work they could not run properly.
In the right lower part of the Welcome to Android Studio screen
click Configure and “Create Desktop Entry” confirm for your user only.
Lock to the panel Android Studio (right click on panel icon).
It is possible to check and review the Memory parametres called Allocated Heap Size
the configuration file for the installation explained is
/opt/android-studio/bin/studio64.vmoptions
For example on a VMware guest with 3GB of RAM the default configuration shown is like
-Xms256m
-Xmx1280m
-XX:ReservedCodeCacheSize=240m
-XX:+UseConcMarkSweepGC
-XX:SoftRefLRUPolicyMSPerMB=50
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPV4Stack=true
…
Some people on the Internet suggest to change the Allocated Heap Size settings, but it is important to know that this kind of customization could cause an unstable behavior and the high probability of unpredictable problems on the system.
Important: the “Xmx” value may be set less or equal to the total amount of the memory of the system (example OS running on 3GB of ram means that the maximum Xmx value could be 3072), but this value should be kept less for more stability, with 3GB of RAM it would be risky set it over 2048.
-Xms128m
-Xmx3072m
-XX:MaxPermSize=1024m
-XX:ReservedCodeCacheSize=200m
Install VirtualBox
Remove other versions of VirutalBox previously installed on the system sudo apt remove virtualbox Add the software source to sources.list sudo vi /etc/apt/sources.list Append the following line
deb http://download.virtualbox.org/virtualbox/debian xenial contrib
Fetch the VirtualBox GPG key wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add – Install VirtualBox (in this example the version is 5.2 but it could be different) sudo apt-get update sudo apt-get install virtualbox-5.2
Install Androidx86 on VirtualBox
How to emulate Android with Oracle VirtualBox on Ubuntu 16 64bit
As illustrated in the previous steps the Ubuntu 16 64bit system could also be a virtualized guest VM running in VMware Workstation Player in a Windows host computer.
Open Firefox and go to the page:
https://sourceforge.net/projects/android-x86/files/Release%204.4/
download the ISO image file of Androidx86, the versions tested for this guide are the “4.4-r1” and the “4.4-r5”.
https://sourceforge.net/projects/android-x86/files/Release%204.4/android-x86-4.4-r1.iso/download
or
https://sourceforge.net/projects/android-x86/files/Release%204.4/android-x86-4.4-r5.iso/download
Search the VirtualBox program using the search button (the first on the left sidebar) and click it to open the Oracle VM VirtualBox Manager
Create a new virtual machine with the following virtual hardware specifications:
Name (choose a name)
Type Linux
Version Other Linux 32
Base Memory 1024 (at least)
Boot Order CD/DVD, Hard Disk
Chipset PIIX3
Pointing Device PS/2 Mouse
Video Memory 128MB
Storage
Controller:IDE
Create a Virtual Hard Disk
type VDI
dinamically allocated
size 8.00GB
CD/DVD Choose CD/DVD disk file (android-x86-4.4-xx.iso)
Audio Enabled
Network NAT Enabled
USB Enabled USB controller
It is suggested to leave not enabled:
I/O APIC, EFI, HW Clock in UTC time, PAE/NX, 3D and 2D acceleration, shared folders.
Start the VM and choose the following actions/options (press enter once selected):
Installation – Install Android-x86 to harddisk
Create/Modify Partitions
if the system asks to use GPT partition select No
inside the cfdisk partition page select and press enter on
New
Primary
(press enter to confirm the suggested size 8xxx.xx)
Bootable (so that the word “Boot” appears in the Flags column)
Write
(type “yes”) and press enter
Quit
select the partition (usually sda1 unknown VBOX HARDDISK)
ext3 (or ext4 if available)
confirm to format
confirm to install GRUB
if asked confirm to NOT install GRUB2
confirm to install /system directory as read-write Select from the VirtualBox menu
devices – optical drives – remove disk from virtual drive
Click the Force Unmount answer when asked
select Reboot, OK and press enter.
At the first screen leave selected “Android-x86 4.4-r1”, or “Android-x86 4.4-r5”
press “e” and press again “e” to edit the first Grub menu entry.
For r1:
Move the cursor with the left arrow and change video=-16 to video=-128
The full startup sequence line will be
grub edit> kernel /android-4.4-r1/kernel quiet root=/dev/ram0 androidboot.hardware=android_x86 video=-128 SRC=/android-4.4-r1
Press enter, then press “b” to load the OS.
For r5 the same procedure could be performed, with the difference that the parameter “video=-128” is to be added before “SRC=/android-4.4-r1”, since there is no “video=-16” parameter.
From now on aavery change made to the system configuration and to the files inside the VM will be remembered since the OS is using its virtual hard drive.
Please note that the system is virtualized so don’t expect it to be as responsive as a real one, at the cost of lag we will have a Development and testing system.
Proceed filling the requested fields and proceed, note that since the network is set to NAT enabled it is not required to enable wifi.
For the first test of the VM is not necessary to use a Google account
Once the main screen is shown click with the mouse on the menu button and choose settings, click on display and set Sleep to “never”.
You can also turn off the services not necessary for a basic development purpose, like for example location, ringtone and notifications, spell checker.
If you plan to transfer APK apps using USB you may allow unknown sources in the security page of the settings.
Useful readings
VirtualBox manual provided by Oracle
https://www.virtualbox.org/manual/UserManual.html
Android 4.4 user manual EN
https://static.googleusercontent.com/media/www.google.com/en//help/hc/images/android/android_ug_42/en-GB_Kitkat-1.11.pdf
Since VirtualBox supports snapshots you may choose how to turn it off.
For a simple shutdown click on the time in the upper right corner and drag down the menu.
Click Power Off andd confirm.
Important: the following set of instructions is potentially disruptive, destructive and dangerous for any file and system where they are executed.
All the following instructions are provided without any warranty for any kind of damage derived by their use, the author and the publisher are not and can never be responsible for any issue or damage darived by or attributed to the present text.
To make permanent the grub menu it is possible to edit the grub configuration that consists in the “menu.lst” file.
This file is protected, and also the access to many commands required to edit it is protected by the system security configuration.
Start the VM
choose “Debug Mode” and press enter
when the prompt is displayed, with a blinking cursor type ls and press enter
to check if the contents of the filesystem are displayed and if the system is accepting commands
Note that the default keyboard layout is EN
Enter the following commands
# mount -o remount,rw /mnt
# cd /mnt/grub
# vi menu.lst
Note that VI is a powerful text editor builtin in Linux, for more details see http://www.lagmonster.org/docs/vi.html
If any mistake or problem happen, you may use this command to close the file without saving it
# :q!
Move the cursor with the down and right arrow to reach the first menu entry usually beginning with the word “kernel”, go to “video=-16” and stop the cursor at the first position at the right of the number “6”
Press i to enable the edit mode (and from now on watch your moves very carefully)
Press backspace to delete the mumber 6 and press 28 so that the setting changes to “video=-128”
The string will look like
kernel /android-4.4-r1/kernel quiet root=/dev/ram0 androidboot.hardware=android_x86 video=-128 SRC=/android-4.4-r1
if so, save and close the file with the commands
# :w
# :q
Complete the safe mode session activity with
# cd /
# umount /mnt
# reboot -f
For r5 version the parameter “video=-128” must be added before “SRC=/android-4.4-r5”
The virtual Android-x86 OS will (hopefully) reboot.
To check if the setting is applied select the first Grub menu entry and press e, again press e.
When done press Enter and b to start the system.
Bonus : a multiple command useful to keep Ubuntu updated, clean and cool :
sudo apt-get update -y && sudo apt-get upgrade -y && sudo apt-get clean && sudo apt-get autoclean && sudo apt-get autoremove -y
Done.
Happy coding!
Links to tutorials about Android Studio :
https://developer.android.com/studio/install
https://www.tutorialspoint.com/android/android_studio.htm
https://linuxhint.com/android-studio-ubuntu-tutorial/
————————- END ————————-


You must be logged in to post a comment.