ionic build Android | error: No installed build tools found. Please install the Android build tools

后端 未结 27 3480
被撕碎了的回忆
被撕碎了的回忆 2020-11-28 05:25

When I run ionic build android command in root of ionic project, I am getting this error:

FAILURE: Build failed with an exception.

相关标签:
27条回答
  • 2020-11-28 06:01

    This works for me! be careful with the new java versions because they cause error, check that you have everything installed and in your specific directory,

    I did not use openJDK

    export JAVA_HOME="/usr/lib/jvm/java-8-jdk" \
    && export PATH=$JAVA_HOME/bin:$PATH \
    && export ANDROID_HOME=$HOME/Android/Sdk \
    && export PATH=${PATH}:${ANDROID_HOME}/tools \
    && export PATH=${PATH}:${ANDROID_HOME}/platform-tools \
    && export GRADLE_HOME=/usr/share/java/gradle/bin/gradle \
    export PATH=$PATH:$GRADLE_HOME/bin
    

    Linux 4.14.39-1-MANJARO #1 SMP PREEMPT Wed May 2 19:03:39 UTC 2018 x86_64 GNU/Linux

    0 讨论(0)
  • 2020-11-28 06:02

    For me running these three commands fix the issue on my Mac:

    export ANDROID_HOME=~/Library/Android/sdk
    export PATH=${PATH}:${ANDROID_HOME}/tools
    export PATH=${PATH}:${ANDROID_HOME}/platform-tools
    

    For ease of copying here's one-liner

    export ANDROID_HOME=~/Library/Android/sdk && export PATH=${PATH}:${ANDROID_HOME}/tools && export PATH=${PATH}:${ANDROID_HOME}/platform-tools
    

    To add Permanently

    Follow these steps:

    1. Open the .bash_profile file in your home directory (for example, /Users/your-user-name/.bash_profile) in a text editor.
    2. Add export PATH="The above exports here" to the last line of the file, where your-dir is the directory you want to add.
    3. Save the .bash_profile file.
    4. Restart your terminal

    Adding to bash process for different systems

    0 讨论(0)
  • 2020-11-28 06:02

    I Search this problem for days.... I hope it will be usefull

    FINAL SOLUTION: (I assume that you have installed Oracle-JDK and ANDROID)

    open /etc/environment with

     sudo nano /etc/environment
    
    
    PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/shoniisra/Android/Sdk/tools:/home/shoniisra/Android/Sdk/platform-tools:/home/shoniisra/Android/Sdk/build-tools:/home/shoniisra/Android/Sdk:/home/shoniisra/android-studio/bin"
    JAVA_HOME="/home/shoniisra/java/jdk1.8.0_231"
    ANDROID_HOME="/home/shoniisra/Android/Sdk/build-tools/29.0.2"
    ANDROID_SDK_ROOT="/home/shoniisra/Android/Sdk"
    ANT_HOME="/home/shoniisra/ant/apache-ant-1.9.14"
    

    Save and exit (CTRL+o CTRL+X)

    Reload file source /etc/environment

    If you recently installed Android you should accept some licences

    cd ~/Android/Sdk/tools/bin/
    

    Execute sdkmanager:

    ./sdkmanager --licenses
    

    Then Accept all, and Finally generate your APK

    cd {yourproyect}
    sudo ionic cordova build android
    
    0 讨论(0)
  • 2020-11-28 06:03

    This issue also occur if you do an upgrade to you cordova installation.

    Check if your log error has something like:

    Checking Java JDK and Android SDK versions
    ANDROID_SDK_ROOT=undefined (recommended setting) <-------------
    ANDROID_HOME=/{path}/android-sdk-linux (DEPRECATED)
    Using Android SDK: /usr/lib/android-sdk
    Starting a Gradle Daemon (subsequent builds will be faster)
    

    In such case, just change ANDROID_HOME to ANDROID_SDK_ROOT in your ~/.bashrc or similar config file.

    Where before was:

    export ANDROID_HOME="/{path}/android-sdk-linux"
    

    Now is:

    export ANDROID_SDK_ROOT="/{path}/android-sdk-linux"
    

    Don't forget source it: $ . ~/.bashrc after edition.

    0 讨论(0)
  • 2020-11-28 06:04

    Type android on your command line and install "Android SDK Build-tools"

    0 讨论(0)
  • 2020-11-28 06:05
    This is very irritating error and i wasted my almost 9 hours to solve this.
    
    Steps to solve:
    
    Notice **ANDROID_HOME** while you run **ionic cordova build android** . command i. for example in my case it was pointing to some other android sdk which i uninstalled and then it started pointing to right sdk.
    **In my case i uninstalled :**
    
    brew cask uninstall android-sdk
    brew cask uninstall android-platform-tool
    
    
    then i ran **ionic cordova build android**
    
    > cordova build android
    ANDROID_HOME=/Users/anand/Library/Android/sdk
    JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home
    
    
    Then it might say lineces not accepted then run below command :
    
    cd /Users/Android/sdk/tools/bin/
    then run ./sdkmanager --licenses
    accepts all with y option
    
    
    Then it might say unable to download jars then go to platform android and build.gradle
    
    and search for buildscript and inside that reverse the order 
    
    
    repositories {
            jcenter()
            maven {
                url "https://maven.google.com"
            }
        }
    
    Thats it . Enjoy huh
    
    0 讨论(0)
提交回复
热议问题