Android使用calabash时SDK路径问题-android

Android SDK path issue when using calabash-android

我在尝试 运行 calabash-android 命令时遇到 "Could not find an Android SDK please make sure it is installed" 错误。我已经通过 brew 安装了 Android SDK。这是我的 .bash_profile:

的内容
ANDROID_HOME=/usr/local/Cellar/android-sdk/24.2
PATH=$PATH:$ANDROID_HOME/tools
PATH=$PATH:$ANDROID_HOME/platform-tools
PATH=$PATH:$ANDROID_HOME/build-tools

if [ -f ~/.bashrc ]; then
        source ~/.bashrc
fi

[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

PATH=$PATH:/usr/local/apache-ant-1.9.4/bin
PATH=$PATH:/usr/local/share/npm/bin
JAVA_HOME=/usr/libexec/java_home

export PATH

这是我的 $PATH:

echo $PATH
/Users/mchumak/.rvm/gems/ruby-2.1.1/bin:/Users/mchumak/.rvm/gems/ruby-2.1.1@global/bin:/Users/mchumak/.rvm/rubies/ruby-2.1.1/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/Cellar/android-sdk/24.2/tools:/usr/local/Cellar/android-sdk/24.2/platform-tools:/usr/local/Cellar/android-sdk/24.2/build-tools:/Users/mchumak/.rvm/bin:/Users/mchumak/.rvm/bin:/opt/local/bin:/opt/local/sbin:/Users/mchumak/.rvm/bin:/usr/local/apache-ant-1.9.4/bin:/usr/local/share/npm/bin

"which android" 产生:

/usr/local/bin/android

该特定文件的内容是:

#!/bin/bash
TOOL="/usr/local/Cellar/android-sdk/24.2/tools/android"
exec "$TOOL" "$@"

我可以从命令行 运行 Android SDK 管理器,它显示正确的 SDK 路径 (/usr/local/Cellar/android-sdk/24.2)。

我被难住了。为什么 calabash-android 找不到 SDK 有什么想法吗?

查看您的 $PATH 输出似乎 android sdk 路径未加载到 PATH 中。将以下内容添加到您的 .bash_profile

路径=$路径:$ANDROID_HOME

这将解决您的问题,

  1. echo "export PATH=$PATH:/Users/#username/Library/Android/sdk/platform-tools/sdk/platform-tools/" >> ~/.bash_profile

  2. 安装 android-platform-tools -> brew install android-platform-tools

- 还要确保自己有管理员权限

calabash-android run /Users/marcg/Downloads/app-news.apk

我收到以下错误

Could not find any platform directory in '/Users/marcg/Library/Android/sdk/platforms'

我用下面的符号链接更正了这个问题:

/Users/marcg/Library/Android/sdk/platforms
platforms$ ln -s ../platform-tools/ platform

我再次 运行 并得到一个错误,android jar 从 /Users/marcg/Library/Android/sdk/platforms

的标准目录中丢失

然后我将 android.jar 复制到这个平台目录

目录现在看起来像:

/Users/marcg/Library/Android/sdk/platforms
us164912:platforms marcg$ ls -l
total 49640
-rwxr-xr-x   1 marcg Users  25409822 Oct  5 09:26 android.jar
lrwxr-xr-x   1 marcg Users        18 Oct  5 09:14 platform -> ../platform-tools/

还在收到

Did not find 'android.jar' in any standard directory of '/Users/marcg/Library/Android/sdk/platforms'. Calabash will therefore take longer to load

我将 android.jar 复制到 platform-tools 目录,剩下的错误消失了。

纠正步骤:

  1. 在指向平台工具的平台中创建符号链接
    ln -s ../platform-tools/ platform
  2. 将android.jar复制到平台工具目录

如果框架允许您通过文件或其他环境变量配置在哪里可以找到它们,那就更好了。我之前尝试将 ANDROID_HOME 设置为 platform-tools 目录没有成功,这也是我为什么要创建符号链接的原因。