Ionic:无法构建android

时间:2016-08-18 16:32:43

标签: android ionic-framework

尝试使用Ionic构建到android时遇到大问题。我最初尝试了正常ionic build android,但是失败了

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

我做了一些搜索堆栈溢出和离子论坛,并安装了Java和Android Studio作为解决方案,它开始安装了很多.jar文件,这发生了:

 Download https://repo1.maven.org/maven2/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar


    Download https://repo1.maven.org/maven2/commons-codec/commons-codec/1.4/commons-codec-1.4.jar


    Download https://repo1.maven.org/maven2/com/android/tools/external/lombok/lombok-ast/0.2.3/lombok-ast-0.2.3.jar


    Download https://repo1.maven.org/maven2/org/abego/treelayout/org.abego.treelayout.core/1.0.1/org.abego.treelayout.core-1.0.1.jar




    FAILURE: Build failed with an exception.

    * What went wrong:
    A problem occurred configuring root project 'android'.
    > failed to find target with hash string 'android-23' in: /Users/.../Library/Android/sdk

    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.


    BUILD FAILED

    Total time: 51.558 secs

    Error: /users/nick/documents/.../.../platforms/android/gradlew: Command failed with exit code 1 Error output:
    FAILURE: Build failed with an exception.

    * What went wrong:
    A problem occurred configuring root project 'android'.
    > failed to find target with hash string 'android-23' in: /Users/.../Library/Android/sdk

    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
    Please install Android target: "android-23".

    Hint: Open the SDK manager by running: /Users/.../Library/Android/sdk/tools/android
    You will require:
    1. "SDK Platform" for android-23
    2. "Android SDK Platform-tools (latest)
    3. "Android SDK Build-tools" (latest)

有什么建议吗?也许我需要卸载Android Studio或其他东西?你可能会说,我对此非常不满意。但这极大地阻碍了我正在努力的项目,如果有人可以提供帮助,那将会很棒!

1 个答案:

答案 0 :(得分:0)

基于Installing the Android Development Environment

根据Android SDK的位置配置 ANDROID_HOME 环境变量。另外,请考虑在您的路径中添加 ANDROID_HOME / tools ANDROID_HOME / platform-tools

对于Mac:

   export ANDROID_HOME=/<installation location>/android-sdk-macosx
  export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

对于Windows:

set ANDROID_HOME=C:\<installation location>\android-sdk-windows
set PATH=%PATH%;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools

对于linux:

export ANDROID_HOME=/<installation location>/android-sdk-linux
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools