Cordova: Android SDK is not set up properly. Make sure that the Android SDK 'tools' and 'Platform-tools' Directories are in the PATH variable

Asked

Viewed 518 times

0

How to fix this error while running command: Ionic Cordova Platform add android ?

ionic cordova platform add android
> cordova platform add android --save
Using cordova-fetch for [email protected]
Adding android project...
Creating Cordova project for the Android platform:
        Path: platforms\android
        Package: io.ionic.starter
        Name: wellfitapp
        Activity: MainActivity
        Android target: android-27
Android project created with [email protected]
Android Studio project detected
Android Studio project detected
Installing "cordova-plugin-advanced-http" for android
Plugin dependency "[email protected]" already fetched, using that version.
Installing "cordova-plugin-file" for android

The Android Persistent storage location now defaults to "Internal". Please check this plugin's README to see if your application needs any changes in its config.xml.

If this is a new application no changes are required.

If this is an update to an existing application that did not specify an "AndroidPersistentFileLocation" you may need to add:

      "<preference name="AndroidPersistentFileLocation" value="Compatibility" />"

to config.xml in order for the application to find previously stored files.

Subproject Path: CordovaLib
Subproject Path: app
Installing "cordova-plugin-device" for android
Installing "cordova-plugin-facebook4" for android
config file res/values/facebookconnect.xml requested for changes not found at C:\projetos\wellfitapp\platforms\android\res\values\facebookconnect.xml, ignoring
config file res/values/facebookconnect.xml requested for changes not found at C:\projetos\wellfitapp\platforms\android\res\values\facebookconnect.xml, ignoring
Subproject Path: CordovaLib
Subproject Path: app
Dependent plugin "cordova-plugin-file" already installed on android.
Installing "cordova-plugin-ionic-keyboard" for android
Installing "cordova-plugin-ionic-webview" for android
Installing "cordova-plugin-splashscreen" for android
Installing "cordova-plugin-whitelist" for android

               This plugin is only applicable for versions of cordova-android greater than 4.0. If you have a previous platform version, you do *not* need this plugin since the whitelist will be built in.

Installing "cordova-plugin-x-socialsharing" for android
Plugin dependency "[email protected]" already fetched, using that version.
Installing "es6-promise-plugin" for android
Subproject Path: CordovaLib
Subproject Path: app
Installing "cordova-plugin-x-toast" for android
Installing "cordova-plugin-youtube-video-player" for android
Installing "cordova-sqlite-storage" for android
installing external dependencies via npm
npm install of external dependencies ok
Failed to install 'cordova-sqlite-storage': Error: ENOENT: no such file or directory, open 'C:\projetos\wellfitapp\platforms\android\AndroidManifest.xml'
    at Object.fs.openSync (fs.js:646:18)
    at Object.fs.readFileSync (fs.js:551:33)
    at Object.parseElementtreeSync (C:\projetos\wellfitapp\platforms\android\cordova\node_modules\cordova-common\src\util\xml-helpers.js:180:27)
    at new AndroidManifest (C:\projetos\wellfitapp\platforms\android\cordova\lib\AndroidManifest.js:29:20)
    at AndroidProject.getPackageName (C:\projetos\wellfitapp\platforms\android\cordova\lib\AndroidProject.js:99:12)
    at Api.addPlugin (C:\projetos\wellfitapp\platforms\android\cordova\Api.js:223:57)
    at handleInstall (C:\Users\Ramos\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\plugman\install.js:594:10)
    at C:\Users\Ramos\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\plugman\install.js:357:28
    at _fulfilled (C:\Users\Ramos\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:787:54)
(node:8584) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open 'C:\projetos\wellfitapp\platforms\android\AndroidManifest.xml'
    at Object.fs.openSync (fs.js:646:18)
    at Object.fs.readFileSync (fs.js:551:33)
    at Object.parseElementtreeSync (C:\projetos\wellfitapp\platforms\android\cordova\node_modules\cordova-common\src\util\xml-helpers.js:180:27)
    at new AndroidManifest (C:\projetos\wellfitapp\platforms\android\cordova\lib\AndroidManifest.js:29:20)
    at AndroidProject.getPackageName (C:\projetos\wellfitapp\platforms\android\cordova\lib\AndroidProject.js:99:12)
    at Api.addPlugin (C:\projetos\wellfitapp\platforms\android\cordova\Api.js:223:57)
    at handleInstall (C:\Users\Ramos\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\plugman\install.js:594:10)
    at C:\Users\Ramos\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\plugman\install.js:357:28
    at _fulfilled (C:\Users\Ramos\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:787:54)
    at self.promiseDispatch.done (C:\Users\Ramos\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:816:30)
(node:8584) 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:8584) [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.
    at self.promiseDispatch.done (C:\Users\Ramos\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:816:30)

When I run Cordova info gives me the following result:

Plugins:

cordova-plugin-advanced-http,cordova-plugin-device,cordova-plugin-facebook4,cordova-plugin-file,cordova-plugin-ionic-keyboard,cordova-plugin-ionic-webview,cordova-plugin-splashscreen,cordova-plugin-whitelist,cordova-plugin-x-socialsharing,cordova-plugin-x-toast,cordova-plugin-youtube-video-player,cordova-sqlite-storage,es6-promise-plugin

Error retrieving Android platform information:
Android SDK is not set up properly. Make sure that the Android SDK 'tools' and 'platform-tools' directories are in the PATH variable.

Error: cmd: Command failed with exit code 1 Error output:
'android' n�o � reconhecido como um comando interno
ou externo, um programa oper�vel ou um arquivo em lotes.

EDITED::

> cordova prepare android
cp: copyFileSync: could not write to dest file (code=ENOENT):C:\projetos\wellfitapp\platforms\android\res\xml\config.xml

Parsing C:\projetos\wellfitapp\platforms\android\res\xml\config.xml failed
(node:940) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open 'C:\projetos\wellfitapp\platforms\android\res\xml\config.xml'
    at Object.fs.openSync (fs.js:646:18)
    at Object.fs.readFileSync (fs.js:551:33)
    at Object.parseElementtreeSync (C:\projetos\wellfitapp\platforms\android\cordova\node_modules\cordova-common\src\util\xml-helpers.js:180:27)
    at new ConfigParser (C:\projetos\wellfitapp\platforms\android\cordova\node_modules\cordova-common\src\ConfigParser\ConfigParser.js:30:24)
    at updateConfigFilesFrom (C:\projetos\wellfitapp\platforms\android\cordova\lib\prepare.js:106:18)
    at Api.module.exports.prepare (C:\projetos\wellfitapp\platforms\android\cordova\lib\prepare.js:42:20)
    at Api.prepare (C:\projetos\wellfitapp\platforms\android\cordova\Api.js:192:45)
    at C:\Users\Ramos\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\cordova\prepare.js:106:36
    at _fulfilled (C:\Users\Ramos\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:787:54)
    at self.promiseDispatch.done (C:\Users\Ramos\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:816:30)
(node:940) 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:940) [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.
  • 1

    How is your configuration file? I asked that question the other day at SO-EN, https://stackoverflow.com/questions/51478914/cordova-plugin-facebook4-how-to-use-it

1 answer

-1


you need to set the variable ANDROID_HOME as an environment variable, without the variable defined, Cordova cannot execute the command android. I recommend reading this article: Setting up android environment

To check if the environment variable has been set, run the command on the terminal: For Linux or macOS

echo $ANDROID_HOME

For windows:

android

The command android should work on both platforms, if you run the android command and receive the message that the command was not found, the variable is not set.

Hugs

Browser other questions tagged

You are not signed in. Login or sign up in order to post.