Search code examples
xamarincalabashcalabash-androidxamarin-test-cloud

calabash-android build in Mac giving [Error]Could not find an Android SDK please make sure it is installed


I am trying to build calabash-android in my mac i am getting the following error

sudo calabash-android build /Users/igate/Downloads/SimpleCreditCardValidator/app/app-release.apk
ERROR: Could not find an Android SDK please make sure it is installed.
ERROR: You can read about how Calabash is searching for an Android SDK and how you can help here:
ERROR: https://github.com/calabash/calabash-android/blob/master/documentation/installation.md#prerequisites
/Library/Ruby/Gems/2.0.0/gems/calabash-android-0.8.0/lib/calabash-android/dependencies.rb:114:in `setup': Could not find an Android SDK (RuntimeError)
    from /Library/Ruby/Gems/2.0.0/gems/calabash-android-0.8.0/lib/calabash-android/dependencies.rb:41:in `java_dependencies'
    from /Library/Ruby/Gems/2.0.0/gems/calabash-android-0.8.0/lib/calabash-android/dependencies.rb:81:in `keytool_path'
    from /Library/Ruby/Gems/2.0.0/gems/calabash-android-0.8.0/lib/calabash-android/helpers.rb:186:in `block (2 levels) in fingerprint_from_apk'
    from /Library/Ruby/Gems/2.0.0/gems/calabash-android-0.8.0/lib/calabash-android/helpers.rb:169:in `chdir'
    from /Library/Ruby/Gems/2.0.0/gems/calabash-android-0.8.0/lib/calabash-android/helpers.rb:169:in `block in fingerprint_from_apk'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/tmpdir.rb:88:in `mktmpdir'
    from /Library/Ruby/Gems/2.0.0/gems/calabash-android-0.8.0/lib/calabash-android/helpers.rb:168:in `fingerprint_from_apk'
    from /Library/Ruby/Gems/2.0.0/gems/calabash-android-0.8.0/bin/calabash-android-build.rb:2:in `calabash_build'
    from /Library/Ruby/Gems/2.0.0/gems/calabash-android-0.8.0/bin/calabash-android:71:in `<top (required)>'
    from /usr/bin/calabash-android:23:in `load'
    from /usr/bin/calabash-android:23:in `<main>'

I also checked my bash_profile for SDK it is perfectly fine as below

export ANDROID_HOME="/Users/igate/Library/Android/sdk"
export PATH="$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools"

Solution

  • as suggested on Calabash installation docs you should not use sudo neither when you install or when you use gems:

    You should never install gems with sudo. If you are having issues installing bundler, we recommend using the Calabash Sandbox or using a managed version of Ruby, e.g. rbenv or rvm.

    In addition, coming back to Android SDK, make sure you download the right SDK from here, unzip the file anywhere you want and insert into your .bash_profile the right paths.

    For example, these are mines (I have unzipped folder into ~/Documents):

    export ANDROID_HOME="$HOME/Documents/android-sdk-macosx"
    export ANDROID_SDK_ROOT="$ANDROID_HOME"
    

    and it works like a charm