Ionic android build Error - Failed to find 'ANDROID_HOME' environment variable

前端 未结 12 1456
庸人自扰
庸人自扰 2020-12-23 19:41

I am trying to build android for ionic in linux but its showing me an error like this

     [Error: Failed to find \'ANDROID_HOME\' environment variable. 
           


        
12条回答
  •  -上瘾入骨i
    2020-12-23 20:03

    Setup for Linux/Ubuntu/Mint

    1. download Android Studio or SDK only
    2. install
    3. set PATH

    3.1) Open terminal and edit ~/.bashrc

    sudo su
    vim ~/.bashrc
    

    3.2) Export ANDROID_HOME and add folders with binaries to your PATH

    Common default install folders:

    • /root/Android/Sdk
    • ~/Android/Sdk

    Example .bashrc

    export ANDROID_HOME=/root/Android/Sdk
    PATH=$PATH:$ANDROID_HOME/tools
    PATH=$PATH:$ANDROID_HOME/platform-tools
    

    3.3) Refresh your PATH

    source ~/.bashrc
    

    4) Install correct SDK

    When ionic build android still fails it could be because of wrong sdk version. To install correct versions and images run android from command line. Since it is now in your PATH you should be able to run it from anywhere.

提交回复
热议问题