This is Gentoo's testing wiki. It is a non-operational environment and its textual content is outdated.

Please visit our production wiki at https://wiki.gentoo.org

Android studio

From Gentoo Wiki (test)
Jump to:navigation Jump to:search
This article is a stub. You can help by expanding it.

This article contains instructions for setting up Android Studio.

Pre-Installation

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:

user $getent group

Run this command to add the user account name which will be using Android Studio to the kvm group with this command:

root #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:

user $groups gentoofan420

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:

user $ls -la /dev/kvm

The desired permissions are mode 660(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:

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

Pulseaudio

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

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 660 and root:kvm.

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:

user $cd ~/Android/Sdk/tools

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

user $./emulator -list-avds

Then try launching an AVD with the command:

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

If you see it, go to

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

or

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

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:

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

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.