Home > front end >  Ionic Failed to find android_sdk_root, cannot build app on phone
Ionic Failed to find android_sdk_root, cannot build app on phone

Time:09-17

When I prompt ionic cordova build android in vscode terminal, after a while it gives me:

Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=undefined (DEPRECATED)
Failed to find 'ANDROID_SDK_ROOT' 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.
[ERROR] An error occurred while running subprocess cordova.

        cordova.cmd build android exited with exit code 1.

        Re-running this command with the --verbose flag may provide more
        information.

[Image of VSCode terminal][1]

I checked my paths and I think it's okay?

[Image of environment variables][2]

Can I get some help please?

I want to test my app on my phone. I already had my phone running on Xamarin.

EDIT(Adding verbose):

Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=undefined (DEPRECATED)
Failed to find 'ANDROID_SDK_ROOT' 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.
CordovaError: Failed to find 'ANDROID_SDK_ROOT' 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.
    at C:\Users\CGarcia\Documents\WorkersAppIONIC\ionic-form-ui\platforms\android\cordova\lib\check_reqs.js:260:19
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Promise.all (index 1)
[ERROR] An error occurred while running subprocess cordova.

        cordova.cmd build android --verbose exited with exit code 1.

        Re-running this command with the --verbose flag may provide more information.
  ionic:utils-process onBeforeExit handler: 'process.exit' received  0ms
  ionic:utils-process onBeforeExit handler: running 2 functions  1ms
  ionic:utils-process error while killing process tree for 6708: Error: Command failed: taskkill /pid 6708 /T /F
  ionic:utils-process ERROR: no se encontr� el proceso "6708".
  ionic:utils-process 
  ionic:utils-process     at ChildProcess.exithandler (child_process.js:308:12)
  ionic:utils-process     at ChildProcess.emit (events.js:315:20)
  ionic:utils-process     at maybeClose (internal/child_process.js:1048:16)
  ionic:utils-process     at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5) {
  ionic:utils-process   killed: false,
  ionic:utils-process   code: 128,
  ionic:utils-process   signal: null,
  ionic:utils-process   cmd: 'taskkill /pid 6708 /T /F'
  ionic:utils-process }  119ms
  ionic:utils-process onBeforeExit handler: error from function: Error: Command failed: taskkill /pid 6708 /T /F
  ionic:utils-process ERROR: no se encontrel proceso "6708".
  ionic:utils-process 
  ionic:utils-process     at ChildProcess.exithandler (child_process.js:308:12)
  ionic:utils-process     at ChildProcess.emit (events.js:315:20)
  ionic:utils-process     at maybeClose (internal/child_process.js:1048:16)
  ionic:utils-process     at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5) {
  ionic:utils-process   killed: false,
  ionic:utils-process   code: 128,
  ionic:utils-process   signal: null,
  ionic:utils-process   cmd: 'taskkill /pid 6708 /T /F'
  ionic:utils-process }  3ms
  ionic:utils-process error while killing process tree for 8984: Error: Command failed: taskkill /pid 8984 /T /F
  ionic:utils-process ERROR: no se encontr� el proceso "8984".
  ionic:utils-process 
  ionic:utils-process     at ChildProcess.exithandler (child_process.js:308:12)
  ionic:utils-process     at ChildProcess.emit (events.js:315:20)
  ionic:utils-process     at maybeClose (internal/child_process.js:1048:16)
  ionic:utils-process     at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5) {
  ionic:utils-process   killed: false,
  ionic:utils-process   code: 128,
  ionic:utils-process   signal: null,
  ionic:utils-process   cmd: 'taskkill /pid 8984 /T /F'
  ionic:utils-process }  7ms
  ionic:utils-process onBeforeExit handler: error from function: Error: Command failed: taskkill /pid 8984 /T /F
  ionic:utils-process ERROR: no se encontrel proceso "8984".
  ionic:utils-process 
  ionic:utils-process     at ChildProcess.exithandler (child_process.js:308:12)
  ionic:utils-process     at ChildProcess.emit (events.js:315:20)
  ionic:utils-process     at maybeClose (internal/child_process.js:1048:16)
  ionic:utils-process     at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5) {
  ionic:utils-process   killed: false,
  ionic:utils-process   code: 128,
  ionic:utils-process   signal: null,
  ionic:utils-process   cmd: 'taskkill /pid 8984 /T /F'
  ionic:utils-process }  3ms
  ionic:utils-process processExit: exiting (exit code: 1)  3ms

EDIT: Now the error is different: (With verbose directly)

Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=C:\Program Files (x86)\Android\android-sdk\tools (recommended setting)
ANDROID_HOME=C:\Program Files (x86)\Android\android-sdk\tools (DEPRECATED)
Using Android SDK: C:\Program Files (x86)\Android\android-sdk\tools
Could not find an installed version of Gradle either in Android Studio,
or on your system to install the gradle wrapper. Please include gradle
in your path, or install Android Studio
CordovaError: Could not find an installed version of Gradle either in Android Studio,
or on your system to install the gradle wrapper. Please include gradle
in your path, or install Android Studio
    at Object.module.exports.check_gradle (C:\Users\CGarcia\Documents\WorkersAppIONIC\ionic-form-ui\platforms\android\cordova\lib\check_reqs.js:131:27)
    at ProjectBuilder.prepEnv (C:\Users\CGarcia\Documents\WorkersAppIONIC\ionic-form-ui\platforms\android\cordova\lib\builders\ProjectBuilder.js:262:27)        
    at Api.module.exports.run (C:\Users\CGarcia\Documents\WorkersAppIONIC\ionic-form-ui\platforms\android\cordova\lib\build.js:168:20)
    at C:\Users\CGarcia\Documents\WorkersAppIONIC\ionic-form-ui\platforms\android\cordova\Api.js:253:47
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

I have Android Studio installed on this computer but never executed it on this user. Should I open it? [1]: https://i.stack.imgur.com/BO5wx.png [2]: https://i.stack.imgur.com/qQ4VE.png

CodePudding user response:

I followed Akshaya Jeevan tips and documentation

  • Related