Android Studio 2.1 Preview 3 _ Unable to create new session on AVD/Emulator

Hello All,

I have Appium 1.4.13 (Draco) installed on OSX 10.11.4 along with Android Studio 2.1 Preview 3.

Since creating new AVDs (API 23 with Google APIs on x86 images with HAX enabled) with Android Studio 2.1 Preview 1 thru 3, I am unable to get Appium to use the Appium Inspector to launch my application on the emulator as needed. Unfortunately, the corporate app I’m helping to test requires the “Android Studio 2.1 Preview” releases, so reverting to older emulators is not an option. This issue is thus a total blocker for all automation efforts on Android.

Currently, Appium will launch the specified emulator just fine, but will then be unable to “find” the running emulator. Specifically, I see the following error in the trace log:

info: [debug] Emulator Nexus_6_API_23 not running

Then after a period of time, an error dialog box is displayed saying the following:

“Could not launch Appium Inspector”
“Could not start a new session”

In the debug trace, you can see the following:

info: [debug] 1 device(s) connected
info: [debug] 1 emulator(s) connected
info: [debug] Sending telnet command to device: avd name
info: [debug] Getting running emulator port
info: [debug] Socket connection to device created
info: [debug] Socket connection to device ready
info: [debug] Telnet command got response: ae[Ke[Dave[Ke[De[Davde[Ke[De[De[Davd e[Ke[De[De[De[Davd ne[Ke[De[De[De[De[Davd nae[Ke[De[De[De[De[De[Davd name[Ke[De[De[De[De[De[De[Davd namee[K
Nexus_6_API_23
info: [debug] Emulator Nexus_6_API_23 not running

Interestingly, when I issue the following command at the terminal:

android list avd

I get the following (note the error):

The following Android Virtual Devices could not be loaded:
Name: Nexus_6_API_23
Path: /Users/me/.android/avd/Nexus_6_API_23.avd
Error: Uknown error

This error happens for ANY AVD created with the Preview release, but I don’t know if it is the cause of Appium’s inability to start a new session with the specified app on the emulator.

When I launch the emulator, via command line like so:

emulator -avd Nexus_6_API_23

The emulator will launch, but the monitor app shows it as:

emulator-5554

rather than by the AVD’s full name.

Here are the settings/capabilities I’m launching with (note the name= setting, I’ve used both Nexus_6_API_23 and emulator-5554, but same failed results with both):

Launching Appium with command: export ANDROID_HOME="/Applications/Android_SDKs/adt-bundle-mac-x86_64-20140702/sdk"; ‘/Applications/Appium.app/Contents/Resources/node/bin/node’ lib/server/main.js --address “127.0.0.1” --command-timeout “999999” --session-override --debug-log-spacing --log-level “debug” --automation-name “Appium” --platform-name “Android” --platform-version “6.0” --app “/Users/me/Desktop/AndroidBuilds/MyApp/app-debug-1.0_134_.apk” --no-reset --dont-stop-app-on-reset --avd “Nexus_6_API_23” --avd-args “-scale .30” --app-pkg “com.obfuscated.activity” --app-activity “com.obfuscated.MainActivity” --device-name “Nexus_6_API_23” --device-ready-timeout “5” --language “en”

Has anyone found a work around for this maddening issue? It has me completely blocked.

Any feedback would be most appreciated!

Thanks,

Larry

This is good troubleshooting on your part. I think you’ve proven that something that Appium depends on is not able to work properly with these new emulators. Could an update of Android SDK fix this issue? I believe that is where the ‘android’ tool comes from, correct?

Yes, I’m thinking that this is an issue with the Android/SDK/adb/emulator tools that are all leveraged by Appium to install and automate applications. Hopefully this post will draw others facing the same issue to comment and heat up the issue enough for a resolution to be implemented, wherever necessary.