question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Could not find a connected Android device" for Android Emulator in mac

See original GitHub issue

I want to using the Android Emulator to run test case. and using the demo code in AndroidUIAutomatorTest.java:

Appium version : Version 1.2.0

public void setup() throws Exception {
  File appDir = new File("src/test/java/io/appium/java_client");
  File app = new File(appDir, "ApiDemos-debug.apk");
  DesiredCapabilities capabilities = new DesiredCapabilities();
  capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
  capabilities.setCapability("deviceName", "Android Emulator");
  capabilities.setCapability("platformName", "Android");
  capabilities.setCapability("app", app.getAbsolutePath());
  driver = new AppiumDriver(new URL("http://10.0.35.216:4723/wd/hub"), capabilities);
}

But get an error message to start android emulator…

“Could not find a connected Android device”

Sever Log as flowing:

2014-07-21T09:55:30.020Z - info: Starting android appium

2014-07-21T09:55:30.018Z - debug: Request received with params: {“desiredCapabilities”:{“app”:“/Users/xpbear/Desktop/appium/java-client/src/test/java/io/appium/java_client/ApiDemos-debug.apk”,“deviceName”:“Android Emulator”,“platformName”:“Android”,“browserName”:“”}} 2014-07-21T09:55:30.019Z - debug: Using local app from desired caps: /Users/xpbear/Desktop/appium/java-client/src/test/java/io/appium/java_client/ApiDemos-debug.apk 2014-07-21T09:55:30.020Z - debug: Creating new appium session fc7161f1-ae40-4a4b-908c-2a0ebe8bd1d7 2014-07-21T09:55:30.021Z - debug: Using fast reset? true 2014-07-21T09:55:30.021Z - debug: Preparing device for session 2014-07-21T09:55:30.021Z - debug: Checking whether app is actually present

2014-07-21T09:55:30.029Z - info: Retrieving device

2014-07-21T09:55:30.029Z - debug: Checking whether adb is present 2014-07-21T09:55:30.029Z - debug: Using adb from /Users/xpbear/Desktop/Android/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/adb 2014-07-21T09:55:30.029Z - debug: Trying to find a connected android device 2014-07-21T09:55:30.030Z - debug: Getting connected devices… 2014-07-21T09:55:30.030Z - debug: executing: “/Users/xpbear/Desktop/Android/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/adb” devices

2014-07-21T09:55:30.045Z - debug: 0 device(s) connected 2014-07-21T09:55:30.045Z - debug: Could not find devices, restarting adb server…

2014-07-21T09:55:35.098Z - debug: executing: “/Users/xpbear/Desktop/Android/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/adb” kill-server

2014-07-21T09:55:35.111Z - debug: Getting connected devices…

2014-07-21T09:55:35.111Z - debug: executing: “/Users/xpbear/Desktop/Android/adt-bundle-mac-x86_64-20140702/sdk/platform-tools/adb” devices

2014-07-21T09:55:38.148Z - debug: 0 device(s) connected

2014-07-21T09:55:50.307Z - debug: Sent shutdown command, waiting for UiAutomator to stop…

2014-07-21T09:55:57.307Z - warn: UiAutomator did not shut down fast enough, calling it gone

2014-07-21T09:55:57.307Z - debug: Cleaning up android objects

2014-07-21T09:55:57.309Z - info: <-- POST /wd/hub/session 500 27292.941 ms - 206

2014-07-21T09:55:57.307Z - debug: Cleaning up appium session 2014-07-21T09:55:57.307Z - error: Failed to start an Appium session, err was: Error: Could not find a connected Android device. 2014-07-21T09:55:57.309Z - debug: Error: Could not find a connected Android device. at ADB.getDevicesWithRetry (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-adb/lib/adb.js:600:15) at androidCommon.prepareActiveDevice (/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/devices/android/android-common.js:349:12) at null.<anonymous> (/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/devices/android/android-common.js:289:26) at /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/async/lib/async.js:610:21 at /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/async/lib/async.js:249:17 at iterate (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/async/lib/async.js:149:13) at /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/async/lib/async.js:160:25 at /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/async/lib/async.js:251:21 at /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/async/lib/async.js:615:34 at androidCommon.prepareEmulator (/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/devices/android/android-common.js:339:5) 2014-07-21T09:55:57.309Z - debug: Responding to client with error: {“status”:33,“value”:{“message”:“A new session could not be created. (Original error: Could not find a connected Android device.)”,“origValue”:“Could not find a connected Android device.”},“sessionId”:null}

Thanks in advance.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:15 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
thanhltxcommented, Mar 7, 2017

it is not same as running test on iOS simulator, with android we need start the Android simulator in advance, I think. Because I passed this issue and be facing to other issue, that is: Original error: 'Command '/Users/username/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell pm list packages com.android.chrome' exited with code 1'; Stderr: 'Error: Could not access the Package Manager. Is the system running?'; Code: '1'

1reaction
imurchiecommented, Feb 1, 2017

So adb is not able to find any devices connected. This sounds like something got messed up with your Android SDK installation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Appium session, could not find a connected Android device ...
Just creating AVD in AVD manager is not sufficient. It has to be up and running (started and ready). To do that, select...
Read more >
Could not find a connected Android device - Appium Discuss
Hi everyone, I am using appium GUI, and I have faced issue "Could not find a connected Android device" Below is full log...
Read more >
Error: Could not find a connected Android device - MagicPod
Error: Could not find a connected Android device · 1. Check the device information · 2. Check the connection of USB cable ·...
Read more >
Troubleshoot known issues with Android Emulator
This page lists known issues, workarounds, and troubleshooting tips for the Android Emulator. If you encounter an issue not listed here or ...
Read more >
How to fix "Android Studio doesn't see device" in Android ...
If Android Studio doesn't even detect your device using 'ADB devices'. then try to switch to PTP instead of MTP on your device....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found