Android Studio 3.0 on Arch Linux, Gnome 3 and Wayland

I did a lot of Android programming during recent years with Java (and some C++). Since Kotlin seemed to be a hype on this years Google I/O I want see what the fuzz is all about. So why not check out the upcoming Android Studio 3.0 at the same time? In addition to the Kotlin integration (which was previously available as plugin) I am also interested in the improved profiling tools.

After downloading AS one of the first things I tried was to created an AVD with Android 7.1.1 on x86_64, KVM enabled with host GPU rendering. Creating the AVD went fine, but it would not start. What the heck?

First I thought this was related to Wayland and not running X11 but after searching online I found that other people also had the same issue. Android Studio comes its own libraries and the libstdc++ seems to be not compatible with the graphics driver. The solution I found to be working is to use -use-system-libs as parameter for the emulator on the command line. Since I do not want to start the emulator from the command line I investigated further and found that adding the following line into the .bashrc would also allow me to start the emulator by pressing the run button in Android Studio.

export ANDROID_EMULATOR_USE_SYSTEM_LIBS=1

Ok, first problem solved.

Then I ran into another issue which at first I thought was related to Kotlin. I started a new project that should use Kotlin. After finishing the setup wizard I had a shiny new “Hello World” project using Kotlin. But Android Studio kept complaining about errors in a generated intermediate values.xml. The problem here seems to be the locale I use on my system. In Germany (de_DE.UTF-8) we use the comma to separate the decimal places whereas in the US (en_US.UTF-8) the decimal point is used. The generated files contained decimal points for floating point value dimensions and Android Studio would check that against the locale and expected commas. To work around this people suggest to change the value of LC_NUMERIC to a locale that uses decimal points which I did not like since I do not want to change the locale settings system wide. So someone suggested to modify the Android Studio startup script (studio.sh) and add an LC_NUMERIC override in there which I did at the beginning of the file.

LC_NUMERIC="en_US.UTF-8"

Second problem solved. Kotlin “Hello World” can now be build and run on the emulator. After all the problems I had were not related to Gnome or Wayland.