Error: ANDROID_HOME is not set and “android” command not in your PATH. You must fulfill at least one of these conditions.

前端 未结 22 1092
闹比i
闹比i 2020-11-22 16:16

I\'m trying to install PhoneGap and I\'m getting the following error:

Error: ANDROID_HOME is not set and "android" command not in your PATH. Yo

22条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-22 16:44

    I have MAC OS X Yosemite, Android Studio 1.0.1, JDK 1.8, and Cordova 4.1.2

    When I tried to add the android project:

    cordova platforms add android
    

    I received the message: ANDROID_HOME is not set and "android" command not in your PATH

    Based in cforcloud's answer... 'Error: the command "android" failed' using cordova and http://developer.android.com/sdk/installing/index.html?pkg=studio I used the following:

    export ANDROID_HOME="/Users//Library/Android/sdk"
    export ANDROID_TOOLS="/Users//Library/Android/sdk/tools/"
    export ANDROID_PLATFORM_TOOLS="/Users//Library/Android/sdk/platform-tools/"
    PATH=$PATH:$ANDROID_HOME:$ANDROID_TOOLS:$ANDROID_PLATFORM_TOOLS
    echo $PATH
    

    When I tried to create the android project, I received this message:

    Creating android project...
    /Users/lg/.cordova/lib/npm_cache/cordova-android/3.6.4/package/bin/node_modules/q/q.js:126
                        throw e;
                              ^
    Error: Please install Android target "android-19".
    

    I ran Android SDK Manager, and installed Android 4.4.2 (API 19) (everything but Glass Development Kit Preview). It worked for me.

    ===

    This is the content of my .bash_profile file.

    export PATH=$PATH:/usr/local/bin
    export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
    launchctl setenv STUDIO_JDK /library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk
    export ANDROID_HOME="/Users//Library/Android/sdk"
    export ANDROID_TOOLS="/Users//Library/Android/sdk/tools"
    export ANDROID_PLATFORM_TOOLS="/Users//Library/Android/sdk/platform-tools"
    PATH=$PATH:$ANDROID_HOME:$ANDROID_TOOLS:$ANDROID_PLATFORM_TOOLS
    

    To edit .bash_profile using Terminal, I use nano. It is easy to understand.

    cd
    nano .bash_profile
    

    I hope it helps.

提交回复
热议问题