Ionic 3 deploy to device, set android_home

2019-03-04 18:35发布

问题:

I do install android studio on ubuntu, and try to deploy to device an Ionic 3 app.

It fails saying no ANDROID_HOME was found :

Failed to find 'ANDROID_HOME' environment variable. Try setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.

How can i discover where is Android Sdk installed ?

I know i can set using export ANDROID_HOME=/path/to/your/sdk, but i can not find it to set the path.

This is the error message: (node:3709) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Failed to find 'ANDROID_HOME' environment variable. Try setting it manually. Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory. (node:3709) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. [23:47:02] lint finished in 4.30 s

I just add to ~/.bashrc : export ANDROID_HOME="$HOME/Android/Sdk" export PATH=$PATH:$ANDROID_HOME/tools

But still get the same error message, how can i check if the path is rigth?

回答1:

First of all you need to add two paths for run ionic app in real device. ANDR0ID_HOME and GRADLE_HOME, and for that you need to open your environment file that is in etc folder, or try this command

sudo -H gedit /etc/environment

after fire this command, gedit is open, set your ANDROID_HOME path like,

ANDROID_HOME="/home/android/Sdk/"

and same like this you need to set GRADLE_HOME path or you also paste it into the PATH variable with ; seperator.

In GRADLE_HOME variable you need to provide the gradle path from the android-studio folder

save it and logged out after logged in your path is set.

After Logged in check into your terminal that path is set or not, by typing this command

echo $ANDROID_HOME
echo $PATH