This article contains instructions for setting up Android Studio.
- 1 Pre-Installation
- 2 KVM and QEMU
- 3 KVM permissions for Android Studio
- 4 Pulseaudio
- 5 Installation
- 6 Troubleshooting
- 7 See also
These pre-installation steps are required for the Android Studio Emulator program to work. Android Studio will still install and work without these steps but the Emulator will either not launch at all or will appear to be working but will give a cryptic message about "waiting for target to come online". Without these pre-installation steps that wait will be indefinite. The major things to remember are that to have a fully functioning Emulator it is required to have KVM enabled in the kernel (which means that the BIOS must support KVM), qemu installed, and pulseaudio installed.
KVM and QEMU
See QEMU article for information on how to set up KVM and install qemu.
KVM permissions for Android Studio
QEMU should automatically create a new
kvm group on the system and there should now be a /dev/kvm device.
Run this command to view all groups on the system to check if
kvm was added:
Run this command to add the user account name which will be using Android Studio to the
kvm group with this command:
usermod -a -G kvm gentoofan420
In the above example
gentoofan420 is the username.
To check that the user was added to the
kvm group you can run the command:
In the above example
gentoofan420 is the username.
Next check that /dev/kvm is set to the correct ownership and mode permissions. This can be done with the command:
ls -la /dev/kvm
The desired permissions are mode
rw-rw----) and the desired ownership should be
root:kvm. If it's not already configured that way set the ownership and permission mode with the following commands:
chown root:kvm /dev/kvm
chmod 660 /dev/kvm
See pulseAudio article for information on how to install pulseaudio.
USE flags for dev-util/android-studio A new Android development environment based on IntelliJ IDEA
emerge --ask dev-util/android-studio
- ~/Android - The SDK lives here.
- ~/AndroidStudioProjects - Projects created in Android Studio are found here.
Launch Android Studio with the command:
Emulator will not launch
Make sure the proper SDK tools and the Emulator are installed. This can be checked by going to Tools --> Android --> SDK Manager. Then click on the SDK Tools tab and make sure that the box next to Android Emulator is checked as well as the boxes next to Android SDK Platform-Tools, and Android SDK Tools.
Emulator still will not launch
Make sure an actual Android Virtual Device (AVD) has been created. Create an AVD by clicking on the green play button underneath the Run menu. Then click on Create New Virtual Device and follow the instructions from Android Studio.
Emulator really still will not launch
See the pre-installation section above and make sure the system supports KVM at the bios level, KVM is enabled correctly in the kernel, qemu is installed, and pulseaudio is installed.
And see the permissions section above and make sure /dev/kvm is set to mode
Emulator really, really still will not launch
Android Studio itself may only give cryptic information or may act as though the emulator is launching but never launch it. In the terminal window Android Studio was launched from there may be vague messages about timeout reached.
To find out what's really going on with the emulator launch it directly from the ~/Android/Sdk/tools/emulator. So:
Then get a list of installed AVDs (Android Virtual Devices) with the command:
Then try launching an AVD with the command:
./emulator -avd Nexus_5X_API_25
Nexus_5X_API_25 is an example AVD name.
Pay attention to the terminal and see if it lists any error messages about missing libraries or other information. This approach was helpful in determining the pulseaudio requirement.
Emulator really, really, really still will not launch
Check in Android Studio Event Log, if you don't see something like:
Emulator: libGL error: unable to load driver: <your driver name>.
Just move to some backup location libstdc++.so.* files you will find there, emulator will try to work on your system libraries. Optionally you may make symbolic link to your own system libstdc++.so.6, for example:
ln -s /usr/lib64/gcc/x86_64-pc-linux-gnu/6.4.0/libstdc++.so.6 libstdc++.so.6
Running Intel x86 Atom images on processors without ssse3 support you may also see warning
Emulator: emulator: WARNING: Host CPU is missing the following feature(s) required for x86 emulation: SSSE3, but images up to API 22 are known to work despite of it (newer don't work). For Intel x86 Atom_64 images warning is:
Emulator: emulator: WARNING: Host CPU is missing the following feature(s) required for x86_64 emulation: SSSE3 SSE4.1 SSE4.2.
Emulator really, really, really, really, still will not launch
"Have you tried unplugging your Gentoo and then plugging it back in?"
Seriously a system reboot might fix the issue so it's worth a shot at this point. Another thing to try is removing the emulator and the SDK and then reinstalling them. Also double check that all the pre-installation stuff was installed and configured correctly.