Hi ferruzoft,
Could you help to solve the similar issue using C#?
I have set all path in bash_profile.
export ANDROID_HOME=/Users/xxx/Library/Android/sdk
export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=${JAVA_HOME}/bin:$PATH
export PATH=${PATH}:${ANDROID_HOME}/tools
export PATH=${PATH}:${ANDROID_HOME}/platforms-tools
export PATH=${PATH}:${ANDROID_HOME}/build-tools/27.0.1
export PATH=${PATH}:${JAVA_HOME}
When I open Appium desktop and start the server at first, everything is fine and enable to detect adb device. Also, using the command line like (appium -p 4723) no issues.
However, if I directly run in visual studio without opening appium server at first,
AppiumServiceBuilder appiumServiceBuilder = new AppiumServiceBuilder()
.UsingAnyFreePort();
AppiumLocalService appiumLocalService = appiumServiceBuilder.Build();
if (!appiumLocalService.IsRunning)
appiumLocalService.Start();
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.SetCapability("deviceName", "EM1");
capabilities.SetCapability("platformVersion", "6.0");
capabilities.SetCapability("platformName", "Android");
capabilities.SetCapability("appPackage", "com.thlonline.telme");
capabilities.SetCapability("appActivity", "com.thlonline.telme.MainActivity");
AndroidDriver<AndroidElement> androidDriver = new AndroidDriver<AndroidElement (appiumLocalService, capabilities);
the error occurs as follows:
[ADB] The ANDROID_HOME environment variable is not set to the Android SDK root directory path. ANDROID_HOME is required for compatibility with SDK 23+. Checking along PATH for adb.
The full log as follows:
[Appium] Welcome to Appium v1.7.2
[Appium] Non-default server args:
[Appium] address: 127.0.0.1
[Appium] Appium REST http interface listener started on 127.0.0.1:4723
[HTTP] --> GET /wd/hub/status {}
[debug] [MJSONWP] Calling AppiumDriver.getStatus() with args: []
[debug] [MJSONWP] Responding to client with driver.getStatus() result: {âbuildâ:{âversionâ:â1.7.2â,ârevisionâ:null}}
[HTTP] <-- GET /wd/hub/status 200 15 ms - 72
[HTTP] --> POST /wd/hub/session {âdesiredCapabilitiesâ:{âdeviceNameâ:âEM1â,âplatformVersionâ:â6.0â,âplatformNameâ:âAndroidâ,âappPackageâ:âcom.thlonline.telmeâ,âappActivityâ:âcom.thlonline.telme.MainActivityâ}}
[debug] [MJSONWP] Calling AppiumDriver.createSession() with args: [{âdeviceNameâ:âEM1â,âplatformVersionâ:â6.0â,âplatformNameâ:âAndroidâ,âappPackageâ:âcom.thlonline.telmeâ,âappActivityâ:âcom.thlonline.telme.MainActivityâ},null,null]
[debug] [BaseDriver] Event ânewSessionRequestedâ logged at 1520906109271 (14:55:09 GMT+1300 (NZDT))
[Appium] Creating new AndroidDriver (v1.37.0) session
[Appium] Capabilities:
[Appium] deviceName: EM1
[Appium] platformVersion: 6.0
[Appium] platformName: Android
[Appium] appPackage: com.thlonline.telme
[Appium] appActivity: com.thlonline.telme.MainActivity
[BaseDriver] Session created with session id: 930fe437-057c-4667-9f42-f09d025b201f
[debug] [AndroidDriver] Getting Java version
[AndroidDriver] Java version is: 1.8.0_131
[ADB] Checking whether adb is present
[ADB] The ANDROID_HOME environment variable is not set to the Android SDK root directory path. ANDROID_HOME is required for compatibility with SDK 23+. Checking along PATH for adb.
[ADB] Error: Could not find adb Please set the ANDROID_HOME environment variable with the Android SDK root directory path.
at Object.wrappedLogger.errorAndThrow (/usr/local/lib/node_modules/appium/node_modules/appium-support/lib/logging.js:69:13)
at ADB.callee$0$0$ (/usr/local/lib/node_modules/appium/node_modules/appium-adb/lib/tools/system-calls.js:127:9)
at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at GeneratorFunctionPrototype.invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
at
Error: Could not find adb Please set the ANDROID_HOME environment variable with the Android SDK root directory path.
at Object.wrappedLogger.errorAndThrow (/usr/local/lib/node_modules/appium/node_modules/appium-support/lib/logging.js:69:13)
at ADB.callee$0$0$ (/usr/local/lib/node_modules/appium/node_modules/appium-adb/lib/tools/system-calls.js:127:9)
at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at GeneratorFunctionPrototype.invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
at
[debug] [AndroidDriver] Shutting down Android driver
[debug] [AndroidDriver] Called deleteSession but bootstrap wasnât active
[MJSONWP] Encountered internal error running command: Error: Could not find adb Please set the ANDROID_HOME environment variable with the Android SDK root directory path.
at Object.wrappedLogger.errorAndThrow (/usr/local/lib/node_modules/appium/node_modules/appium-support/lib/logging.js:69:13)
at ADB.callee$0$0$ (/usr/local/lib/node_modules/appium/node_modules/appium-adb/lib/tools/system-calls.js:127:9)
at tryCatch (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:67:40)
at GeneratorFunctionPrototype.invoke [as _invoke] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:315:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:100:21)
at GeneratorFunctionPrototype.invoke (/usr/local/lib/node_modules/appium/node_modules/babel-runtime/regenerator/runtime.js:136:37)
at
[HTTP] <-- POST /wd/hub/session 500 265 ms - 246
I investigated the whole day, looks like in Java needs to set ANDROID_HOME in the IDE, but I donât know how to do this in visual studio using C#. Please help, many thanks!