12

I'm getting a "Could not find an Android SDK please make sure it is installed" error when trying to run calabash-android commands. I've installed the Android SDK via brew. Here are the contents of my .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

Here's my $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" produces:

/usr/local/bin/android

The contents of that particular file are:

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

I can run the Android SDK Manager from the command line just fine, and it shows the correct SDK path (/usr/local/Cellar/android-sdk/24.2).

I'm stumped. Any ideas why calabash-android can't find the SDK?

Towercap
  • 175
  • 1
  • 8
  • Calabash uses adb. Does 'adb' work properly? Also what does 'which adb' return? – alannichols May 26 '15 at 09:04
  • @alannichols I can start a server using adb successfully. `which adb` returns `/usr/local/bin/adb`. The contents of that file are `PLATFORM_TOOL="/usr/local/Cellar/android-sdk/24.2/platform-tools/adb"` `test -x "$PLATFORM_TOOL" && exec "$PLATFORM_TOOL" "$@"` `echo "It appears you do not have 'Android SDK Platform-tools' installed."` `echo "Use the 'android' tool to install them: "` `echo " android update sdk --no-ui --filter 'platform-tools'"` – Towercap May 26 '15 at 22:30
  • Hmm, my only guess would be that it's something to do with the linking from eg. /usr/local/bin/adb to where it's actually installed, /usr/local/Cellar/android-sdk/24.2/platform-tools/adb. Can you try removing the android commands from /usr/local/bin/ and try it again. My setup doesn't have the commands linked from /usr/local/bin/ but other than that I think it looks fine. If that doesn't work I'd suggest a manual install. – alannichols May 27 '15 at 09:08
  • @alannichols Unfortunately removing the alias files from /usr/local/bin/ didn't solve it. `which android` returns the correct immediate path (`/usr/local/Cellar/android-sdk/24.2/tools/android`), but I'm still getting the same error. I'll try installing the gem manually. – Towercap May 27 '15 at 23:58
  • Still getting the same issue after installing the gem manually. – Towercap May 28 '15 at 00:05
  • Sorry I meant to try installing the sdk manually, i.e. not with brew and to point ANDROID_HOME to there and see how you get on. – alannichols May 28 '15 at 16:25
  • Choose the answer :) – Aravin Nov 22 '16 at 18:18

3 Answers3

3

This will fix your issue,

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

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

- Also ensure yourself have admin rights

dav_i
  • 27,509
  • 17
  • 104
  • 136
Aravin
  • 6,605
  • 5
  • 42
  • 58
0

Looking at your $PATH output seems like android sdk path isnt loaded into PATH. Add below to your .bash_profile

PATH=$PATH:$ANDROID_HOME

trial999
  • 1,646
  • 6
  • 21
  • 36
  • Thanks for your reply. I've changed the .bash_profile to add ANDROID_HOME to the PATH variable and started a new bash instance, but unfortunately I'm still getting the same error. – Towercap Jul 07 '15 at 01:37
0
calabash-android run /Users/marcg/Downloads/app-news.apk

I received that following error

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

I corrected this with the symlink below:

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

I ran again and get an error that the android jar was missing from a standard directory of /Users/marcg/Library/Android/sdk/platforms

I then copied that android.jar to this platforms dir

Dir now looks like:

/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/

Still getting

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

I copied the android.jar to the platform-tools directory and remaining error went away.

Steps to correct:

  1. Make a symlink in platforms that points to platform-tools
    ln -s ../platform-tools/ platform
  2. Copy the android.jar to the platform-tools dir

Would be better if the framework allowed you configure via file or additional env vars where to find each of these. My earlier attempt to set ANDROID_HOME to the platform-tools dir didn't work and why I did a symlink.

Jeff
  • 12,555
  • 5
  • 33
  • 60
mgraff
  • 11
  • 2