Android studio

From Gentoo Wiki
Jump to:navigation Jump to:search

This article contains instructions for installing Android Studio.

Pre-Installation

These pre-installation steps are required for the Android Studio Emulator to work. The package will still install and partially work without these steps, but the Emulator will either not launch, or may seem to be working but will give a cryptic message about "waiting for target to come online".

To have a fully functioning Emulator, it is required to have KVM enabled in the kernel (which means that the CPU and 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.

QEMU should automatically create a new kvm group on the system and there should now be a /dev/kvm device.

Show all groups on the system to check if kvm was added:

user $getent group

Add the user account which will be using Android Studio to the kvm group (in the example, the username is larry):

root #usermod -a -G kvm larry

To check that the user was added to the kvm group:

user $groups larry

Log out then back in, if already connected with this account.

Make sure /dev/kvm is set to the correct ownership and mode permissions:

user $ls -la /dev/kvm

The desired permissions are mode 660(rw-rw----) and the desired ownership should be root:kvm. This should already be set, if not, set the ownership and permission mode with the following commands:

root # chown root:kvm /dev/kvm
root # chmod 660 /dev/kvm

Pulseaudio

See the PulseAudio article for information on how to install PulseAudio.

Installation

USE flags

USE flags for dev-util/android-studio Android development environment based on IntelliJ IDEA

selinux !!internal use only!! Security Enhanced Linux support, this must be set by the selinux profile or breakage will occur

Emerge

root #emerge --ask dev-util/android-studio

Files

  • ~/Android - the SDK lives here
  • ~/AndroidStudioProjects - projects created in Android Studio are found here

Invocation

Launch Android Studio with the command:

user $android-studio

Troubleshooting

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.

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.

See the pre-installation section above and make sure that the system supports KVM at the bios and processor level, that KVM is enabled correctly in the kernel, and that qemu and pulseaudio are correctly installed and working. Make sure /dev/kvm is set to mode 660 and root:kvm, as described in the pre-installation section.

Android Studio itself may only give cryptic information or may act as though the emulator is launching but never launch it. In the terminal where Android Studio was launched, 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:

user $cd ~/Android/Sdk/tools

Then get a list of installed AVDs (Android Virtual Devices) with the command:

user $./emulator -list-avds

Try launching an AVD:

user $./emulator -avd Nexus_5X_API_25

Where 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.

Check in Android Studio Event Log, particularly for something like: Emulator: libGL error: unable to load driver: <your driver name>. In this case, go to

user $cd ~/Android/Sdk/emulator/lib64/libstdc++/

or

user $cd ~/Android/Sdk/emulator/lib/libstdc++/

and move to some backup location the libstdc++.so.* files from there. Now the emulator will try to work with the system libraries. Optionally, make symbolic link to the system libstdc++.so.6, for example:

user $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 may also give the 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 doesn't). For Intel x86 Atom_64 images, the warning is: Emulator: emulator: WARNING: Host CPU is missing the following feature(s) required for x86_64 emulation: SSSE3 SSE4.1 SSE4.2.

A system reboot might fix the issue so it's worth a shot if all else fails. Another thing to try is removing the emulator and the SDK and then reinstalling them. Also double check that all the pre-installation was followed correctly.

Emulator will crash Android Studio

Try uninstalling and installing the emulator (in the built-in SDK Manager).

See also

  • qemu — a generic, open source hardware emulator and virtualization suite.
  • VirtualBox — cross-platform virtualization software that allows users to run guest operating systems inside a host operating system without having to reboot.

External resources

  • adasss overlay - An overlay containing Android Studio (official, beta, and canary) experimental ebuilds.