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

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.

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 15 (4 by maintainers)

Most upvoted comments

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'

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