Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emulator on Android Studio doesn't start after SDK tools update to 25.3.1

After updating my Android SDK tools today to 25.3.1, the emulator won't run anymore.

I can open the AVD Manager. When I hit "Play" on one of the emulators on the list, I see the bar below on Android Studio

enter image description here

But then after the progress bar reaches the end, nothing happens.

I see in the release notes that the latest update brought changes to the emulator so I'm wondering if that's a bug or I'm missing something about that.

I'm using Android Studio 2.3.

Any ideas?

like image 276
Mateus Gondim Avatar asked Mar 07 '17 22:03

Mateus Gondim


People also ask

Why is my emulator not working Android Studio?

If the Android Emulator does not start properly, this problem is often caused by problems with HAXM. HAXM issues are often the result of conflicts with other virtualization technologies, incorrect settings, or an out-of-date HAXM driver. Try reinstalling the HAXM driver, using the steps detailed in Installing HAXM.


2 Answers

I ran into the same problem after upgrading. I can't figure out what's causing the configuration problem but I did figure out a workaround.

First, I tried to launch the emulator from the command line:

$ emulator @<name_avd_image> emulator: ERROR: This AVD's configuration is missing a kernel file! Please ensure the file "kernel-ranchu" is in the same location as your system image. emulator: ERROR: ANDROID_SDK_ROOT is defined (<android>/sdk) but cannot find kernel file in <android>/sdk/system-images/ sub directories 

You can get more information if you run emulator with the -verbose flag. I tried re-installing the system image (e.g. Android API 25 x86 w/ Google APIs), Android Emulator 25.3.1, and re-creating the AVD but nothing worked.

Finally as a workaround, I just copied all of the system files from the SDK system images directory into the AVD directory:

Example: Pixel XL (Android API 25 x86 w/ Google APIs)
SOURCE: <android>/sdk/system-images/android-25/google_apis/x86/
DESTINATION: ~/.android/avd/Pixel_XL_API_25.avd/

After that the emulator started right up. It's not ideal, but this was blocking my development so I had to get the emulator up and running again. I hope someone else will be able to figure out what broke in the configuration.


UPDATE: Figured out the configuration problem!

I noticed I periodically was seeing the console error "Your emulator is out of date, please update by launching Android Studio:" so I decided to check:

$ which emulator <$ANDROID_SDK_ROOT>/tools/emulator 

With help from this thread:

The problem is there are two emulators: one in $ANDROID_SDK_ROOT/tools, another one in $ANDROID_SDK_ROOT/emulator. The one in $ANDROID_SDK_ROOT/tools cannot start. Place $ANDROID_SDK_ROOT/emulator before $ANDROID_SDK_ROOT/tools in your $PATH variable, it should fix the problem.

NOTE: For most Mac users, you can edit your ~/.bash_profile to change these settings and then run $source ~/.bash_profile to load the updates. In my particular case, I also had old values for $ANDROID_HOME that I had to clear out.

like image 176
Funktional Avatar answered Oct 08 '22 11:10

Funktional


The real problem, at least over Ubuntu 16.10 and 17.04 and Andoid Studio 2.4 Preview 7 (but could happen with any Debian derivative and previous versions of Android Studio), is that Google is distributing a non working libstdc++ library with the emulator tools. They're distributing 6.0.18 version, but i found that the working one is 6.0.22.

EDIT: There are reports that 6.0.21 version of libstdc++ works as well as 6.0.22.

So, you have 2 options:

Option 1

rm the previous non working Google's libs in /yoursdkpàth/emulator/lib64/libstdc++

Download and extract libs from libstdc++ official package in /yoursdkpàth/emulator/lib64/libstdc++

Don't try to install the .deb, extract the files/binaries from inside it (the 2 binaries are in a folder named "lib") and manuallly copy them on the recommended path.

Option 2

Create a simlink to the lib distributed with Ubuntu, which already is 6.0.22 version

cd ~/Android/Sdk/emulator/lib64/libstdc++/  mv libstdc++.so.6 libstdc++.so.6.bak  mv libstdc++.so.6.0.18 libstdc++.so.6.0.18.bak  ln -sf /usr/lib/x86_64-linux-gnu/libstdc++.so.6 ~/Android/Sdk/emulator/lib64/libstdc++/libstdc++.so.6  ln -sf /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.22 ~/Android/Sdk/emulator/lib64/libstdc++/libstdc++.so.6.0.22 

IMPORTANT 1: As Google seems to be not aware of the problem, on every update they make to the Android Emulator package in Android Studio, they break the funcionality replacing your working SDK C++ libs with the broken/older ones. The solution is to repeat any of the above procedures.

IMPORTANT 2: This is only valid if your AVDs are configured for use your PC GPU as host for video accelaration (Hardware GLES 2.0). Selecting Sofware GLES 2.0 on your AVD will work without any of the suggested changes, but your emulator will turn painfully slow.

like image 40
Martin Revert Avatar answered Oct 08 '22 10:10

Martin Revert