How to setup connection between Android Studio and Emulated Device?

Hi I created a device on Android Studio and I’m trying to use it on Appium Studio. I already enabled developer mode and clicked on Enable USB Debbuging. Appium Studio recognizes the emulated device but it says that the device is Offline but the device is opened.
My question is: what am I doing of wrong or is that a bug?

Here is the evidence of what’s happening

I am also facing the same issue, The problem is whenever we add the device, the device shows in “Ready” State but within 5 seconds the devices goes to offline!! but when i verify the device in command line “adb devices - the emulator is connected”

My guess is that there is a clash of ADB versions on your PCs

try running the following commands from CMD (win) or Terminal (MAC)

where adb - for windows
which adb - for MAC OSX

the output should be a list of directories - for which ADB.exe is being used for in PATH (By order)

I’m guessing you’ll find there ADB.exe from Android SDK or studio

your best chance of resolving this item with Appium Studio is to replace (overwrite) the ADB you’ll see their with the ADB located in Appium Studio installation folder

<Installation dir>\bin\adb\adb.exe 

keep a copy of the old file before you overwrite

if this doesn’t help kindly share the log files

https://docs.experitest.com/display/TD115/AS-+Collect+Support+Data

Hello Tom,
I have copied the adb from the appium studio but still the virtual device goes offline hence i am not able to get the log from the system.

Environment : Windows 7
Steps:

  1. create a Virtual device in android
    2 Make sure the emulator is connected by verifying in command line adb devices
  2. add the virtual device in appium studio
  3. Verify the device status

Hello Mali,

Please supply us with the support data - it is alright if the device log is missing.

I am facing the same issue.
Performed all the steps mentioned in the above

  • Emulator is working fine with Android Studio.
  • USB debugging is enabled for the emulator.
  • replaced the adb.exe from Appium Studio installation to the Android Studio installation.
    Appium Studio log file contains following entry of the error

But still issue is continued.
Adding AppiumStudio log file contains

2018-06-05 17:31:28,313 [main] (device.d.a) DEBUG D:\AndroidSDK\platform-tools\adb.exe
2018-06-05 17:31:28,695 [Init Local ADB Bridge] (device.d.a) DEBUG create new adb bridge: 127.0.0.1:5037
2018-06-05 17:31:28,696 [Init Local ADB Bridge] (device.d.a) DEBUG init adb bridge configuration
2018-06-05 17:31:28,785 [Init Local ADB Bridge] (device.d.a) DEBUG Create local bridge C:\Program Files (x86)\Experitest\AppiumStudio\bin\adb\adb.exe
2018-06-05 17:31:30,406 [Init Local ADB Bridge] (device.d.a) DEBUG Create bridge
2018-06-05 17:31:30,459 [pool-4-thread-1] (device.d.a) DEBUG Connect: emulator-5554 online: true
2018-06-05 17:31:30,460 [Device List Monitor] (imagestudio.ImageStudioApp) ERROR Thread [Thread[Device List Monitor,5,main]] got unexpected exception.
java.lang.NoClassDefFoundError: com/android/prefs/AndroidLocation$AndroidLocationException
at com.android.ddmlib.DeviceMonitor.queryAvdName(DeviceMonitor.java:248)
at com.android.ddmlib.DeviceMonitor.updateDevices(DeviceMonitor.java:220)
at com.android.ddmlib.DeviceMonitor.access$400(DeviceMonitor.java:65)
at com.android.ddmlib.DeviceMonitor$DeviceListUpdateListener.deviceListUpdate(DeviceMonitor.java:662)
at com.android.ddmlib.DeviceMonitor$DeviceListMonitorTask.processIncomingDeviceData(DeviceMonitor.java:847)
at com.android.ddmlib.DeviceMonitor$DeviceListMonitorTask.run(DeviceMonitor.java:781)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: com.android.prefs.AndroidLocation$AndroidLocationException
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
… 7 more