问题
Happy new year all, I'd gratefully appreciate if someone could help or shed some light into this issue.
I've just set up appium 1.7.2 server on MAC OS High Sierra v 10.13.2, running appium through below command.
appium -a 127.0.0.1 -p 4723 --log-level=debug
Below is my .bash_profile
n.nadarajah@EGHJ-MACRDV01 ~ $ cat ~/.bash_profile
# Setting PATH for Python 2.7
# The original version is saved in .bash_profile.pysave
ANDROID_HOME=/Users/n.nadarajah/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home
ANDROID_PLATFORM_TOOLS=$ANDROID_HOME/platform-tools
ANDROID_TOOLS=$ANDROID_HOME/tools
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}:$JAVA_HOME:$ANDROID_HOME:
$ANDROID_PLATFORM_TOOLS:$ANDROID_TOOLS"
export PATH
Echoing $ANDRIOD_HOME env variable
n.nadarajah@EGHJ-MACRDV01 ~ $ echo $ANDROID_HOME
/Users/n.nadarajah/Library/Android/sdk
Below are the Appium logs on test execution.
n.nadarajah@EGHJ-MACRDV01 ~ $ appium -a 127.0.0.1 -p 4723 --log-l .
level=debug
info: Welcome to Appium v1.4.16 (REV
ae6877eff263066b26328d457bd285c0cc62430d)
info: Appium REST http interface listener started on 127.0.0.1:4723
info: [debug] Non-default server args: {"address":"127.0.0.1"}
info: Console LogLevel: debug
info: --> POST /wd/hub/session {"capabilities":{"alwaysMatch":
{"platformName":"Android"},"firstMatch":
[{}]},"desiredCapabilities":{"deviceName":"Android
Emulator","app":"/Users/n.nadarajah/sites/Resilient-
QA/EndToEndTesting/apks/app-
debug.apk","platformName":"Android","automationName":"appium",
"appPackage":"com.resilientplc.smartnumbers.debug"}}
info: Client User-Agent string: Python http auth
info: [debug] No appActivity desired capability or server param.
Parsing from apk.
info: [debug] Using local app from desired caps:
/Users/n.nadarajah/sites/Resilient-QA/EndToEndTesting
/apks/app-debug.apk
info: [debug] Creating new appium session
a5cfbee9-bcd6-41af-a90c-0389ab244d2c
info: Starting android appium
info: [debug] Getting Java version
info: Java version is: 1.8.0_151
info: [debug] Checking whether adb is present
warn: 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.
info: [debug] executing cmd: which adb
info: [debug] Using adb from /Users/n.nadarajah/
Library/Android/sdk/platform-tools/adb
info: [debug] Parsing package and activity from app manifest
info: [debug] Checking whether aapt is present
warn: 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 aapt.
info: [debug] executing cmd: which aapt
error: Problem parsing package and activity from manifest: Error: Could
not find aapt. Please set the ANDROID_HOME environment
variable with the Android SDK root directory path.
info: [debug] Cleaning up android objects
info: [debug] Cleaning up appium session
error: Failed to start an Appium session, err was: Error: Could not
find aapt. Please set the ANDROID_HOME environment variable
with the Android SDK root directory path.
info: [debug] Error: Could not find aapt.
Please set the ANDROID_HOME environment variable with the
Android SDK root directory path.at ADB.<anonymous>
(/usr/local/lib/node_modules/appium
/node_modules/appium-adb/lib/adb.js:126:12)
at ChildProcess.exithandler (child_process.js:279:5)
at ChildProcess.emit (events.js:159:13)
at maybeClose (internal/child_process.js:943:16)
at Socket.stream.socket.on (internal/child_process.js:363:11)
at Socket.emit (events.js:159:13)
at Pipe._handle.close [as _onclose] (net.js:568:12)
info: [debug] Responding to client with error: {"status":33,"value":
{"message":"A new session could not be created.
(Original error: Could not find aapt. Please set the ANDROID_HOME
environment variable with the Android SDK root
directory path.)","origValue":"Could not find aapt. Please set the
ANDROID_HOME environment variable with the
Android SDK root directory path."},"sessionId":null}
info: <-- POST /wd/hub/session 500 164.317 ms - 344
Questions: 1. Why does appium cannot see the system environment variable?
I've tried appium server versions 1.7.2 & 1.7.1 & 1.6.2 & 1.4.16 the symptoms were the same. Could someone help me out with this please.
Thanks Niro
回答1:
I've got to the bottom of this issue, turns out I've missed another android env variable.
In the above case I've missed ANDROID_BUILD_TOOLS
At the point of writing this, below are the list of Env variables required for appium.
ANDROID_HOME=/Users/n.nadarajah/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/
Contents/Home/bin
ANDROID_PLATFORM_TOOLS=$ANDROID_HOME/platform-tools
ANDROID_TOOLS=$ANDROID_HOME/tools
ANDROID_BUILD_TOOLS=$ANDROID_HOME/build-tools/27.0.3
Append all the above env variables to $PATH
回答2:
works for me in Mojave.
After editing ~/.bash_<profile or rc>
I use:
source ~/.bash_<profile or rc>
It not only loads the new variables values, as reports any error on file as well.
回答3:
here is the workin list of environment variables:
export ANDROID_HOME=/Users/user/Library/Android/sdk
export PATH=$ANDROID_HOME/:$PATH
export PATH=$ANDROID_HOME/platform-tools/:$PATH
export PATH=$ANDROID_HOME/tools/:$PATH export PATH=/usr/local/bin/:$PATHlaunchctl setenv ANDROID_HOME /Users/user/Library/Android/sdk
works on highSierra, of course, tweak Your paths...
来源:https://stackoverflow.com/questions/48191990/appium-android-home-env-variable-issues