How do I configure an Android device for Appium? “…that device hasn't been configured. Run config”
Question
I'm working on a MacBook Pro with iOS 10.9.4
My Android phone has developer mode and usb debugging turned on.
Running adb devices gives:
List of devices attached
74069667 device
and lists nothing if I disconnect the device and run it again. So I know it's connected.
The main code in my test is:
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("browserName", "Chrome");
capabilities.setCapability("deviceName", "74069667");
URL wd = new URL("http://127.0.0.1:4723/wd/hub");
driver = new RemoteWebDriver(wd, capabilities);
From there, the test goes on with sample code from SauceLabs (and the guinea-pig page is up, I checked):
driver.get("http://saucelabs.com/test/guinea-pig");
Thread.sleep(1000);
WebElement idElement = driver.findElement(By.id("i_am_an_id"));
In a browser, 127.0.0.1:4723/wd/hub/status gives:
{"status":0,"value":{"build":{"version":"1.2.0","revision":"11fcdd5a3fb795c7cf7fa59e50e771ae878ccc68"}}}
So I think that server is OK.
When I run my test with maven (version 3.2.2):
mvn -Dtest=com.saucelabs.appium.androidBrowserTest test
the console for Appium (running version 1.2.0) shows:
info: --> POST /wd/hub/session {"desiredCapabilities":{"platformName":"Android","deviceName":"74069667","browserName":"Chrome"}}
error: Trying to run a session for device 'chrome' but that device hasn't been configured. Run config
debug: Got configuration error, not starting session
debug: Cleaning up appium session
error: Failed to start an Appium session, err was: Error: Device chrome not configured yet
debug: Error: Device chrome not configured yet
at Appium.configure (/usr/local/lib/node_modules/appium/lib/appium.js:267:15)
*<snip>*
and the test doesn't return from the new RemoteWebDriver line.
which config returns nothing and Appium doesn't have a --config setting.
I'm wondering if the error message is a red herring.
Solution
I was running from an installed appium. A person on the appium hipchat suggested I run from source, as shown on this page:
https://github.com/appium/appium/blob/master/CONTRIBUTING.md#using-appium
For whatever reason, things appear to be happy.
OTHER TIPS
It seems you don't have Chromedriver configured in your environment variables.
https://sites.google.com/a/chromium.org/chromedriver/home
Appium needs Chromedriver to open a Chrome/Chromium browser in your device.