2

I am trying to install Ionic in my Linux and trying to check how to run the app. I have successfully installed it and run it on browser.

However, I want to run the app on my Android device.

I have tried to run the command ionic cordova run android --device but it gives following error:

(node:11992) UnhandledPromiseRejectionWarning: CordovaError: Failed to find 'ANDROID_HOME' environment variable. Try setting it manually. Detected 'adb' command at /usr/bin but no 'platform-tools' directory found near. Try reinstall Android SDK or update your PATH to include valid path to SDK/platform-tools directory. at /home/seven-bits-pc11/myApp/platforms/android/cordova/lib/check_reqs.js:287:27 at _fulfilled (/home/seven-bits-pc11/myApp/platforms/android/cordova/node_modules/q/q.js:854:54) at self.promiseDispatch.done (/home/seven-bits-pc11/myApp/platforms/android/cordova/node_modules/q/q.js:883:30) at Promise.promise.promiseDispatch (/home/seven-bits-pc11/myApp/platforms/android/cordova/node_modules/q/q.js:816:13) at /home/seven-bits-pc11/myApp/platforms/android/cordova/node_modules/q/q.js:877:14 at runSingle (/home/seven-bits-pc11/myApp/platforms/android/cordova/node_modules/q/q.js:137:13) at flush (/home/seven-bits-pc11/myApp/platforms/android/cordova/node_modules/q/q.js:125:13) at process._tickCallback (internal/process/next_tick.js:150:11) at Function.Module.runMain (module.js:705:11) at startup (bootstrap_node.js:193:16) (node:11992) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:11992) [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.

I have also tried this solution, but same error is displayed.

Edit:

I have also tried this other solution.

JimHawkins
  • 4,843
  • 8
  • 35
  • 55
Riddhi Shah
  • 3,092
  • 5
  • 36
  • 56

2 Answers2

1

I solved it by correcting the path of ANDROID_HOME as it was mentioned in the links in the question. links: https://stackoverflow.com/a/36201240/8730233 and https://stackoverflow.com/a/41137754/3342570.

So, I changed it

export ANDROID_HOME=/<installation location>/android-sdk-linux

to

export ANDROID_HOME=/<installation location>/

and my error solved.

Riddhi Shah
  • 3,092
  • 5
  • 36
  • 56
0

By seeing your error we can say straight forward there is problem with your Android SDK setup.

Download latest Android SDK from official site.

You can setup ANDROID_HOME path variable to /sdk-installation-directory/ by adding line in ~/.profile or ~/bashrc files on linux system

export ANDROID_HOME="/sdk-installation-directory"

Abhay
  • 3,151
  • 1
  • 19
  • 29