Add android platform in ionic.3

D:\IOnic_sample\myapp>ionic cordova platform add android
? The Ionic CLI (local version) has an update available (3.6.0 => 4.1.1)! Would
 you like to install it? No
[INFO] Not automatically updating your CLI. You can update manually:

       npm install --save-dev --save-exact ionic@latest

? Local plugin @ionic/cli-plugin-cordova has an update available (1.4.1 => 1.6.
2)! Would you like to install it? No
[INFO] Not automatically updating @ionic/cli-plugin-cordova. You can update
       manually:

       npm install --save-dev --save-exact @ionic/cli-plugin-cordova@latest

> cordova platform add android --save
x Running command - failed!

[ERROR] Cordova encountered an error.
        You may get more insight by running the Cordova command above directly.

[ERROR] An error occurred while running cordova platform add android --save
        (exit code 1):

        Using cordova-fetch for cordova-android@~6.3.0
        Error: Failed to fetch platform cordova-android@~6.3.0
        Probably this is either a connection problem, or platform spec is
        incorrect.
        Check your connection and platform name/version/URL.
        Error: cmd: Command failed with exit code ENOENT

--------------ionic info-------------

global packages:

    Cordova CLI : 7.1.0

local packages:

    @ionic/app-scripts        : 3.1.11
    @ionic/cli-plugin-cordova : 1.4.1
    Cordova Platforms         : none
    Ionic Framework           : ionic-angular 3.9.2

System:
    Node : v8.11.3
    OS   : Windows 7

Hi, @Riyaz_ionic

I hope ou have added Android SDK in your machine and also set enviroment variable.

thanks,

yes i have Android sdk

here are the below cause

D:\IOnic_sample\myapp>cordova requirements
Android Studio project detected

Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: installed android-28,android-27,android-26,android-25,android-24
,android-23,android-22,android-21,android-20,android-19,android-18,android-17,an
droid-16,android-15,android-14
Gradle: installed D:\Android_sdk\gradle\gradle-4.4\bin\gradle

D:\IOnic_sample\myapp>ionic cordova run android
? The Ionic CLI (local version) has an update available (3.6.0 => 4.1.1)! Would
you like to install it? No
[INFO] Not automatically updating your CLI. You can update manually:

   npm install --save-dev --save-exact ionic@latest

? Local plugin @ionic/cli-plugin-cordova has an update available (1.4.1 => 1.6.
2)! Would you like to install it? No
[INFO] Not automatically updating @ionic/cli-plugin-cordova. You can update
manually:

   npm install --save-dev --save-exact @ionic/cli-plugin-cordova@latest

Running app-scripts build: --address 0.0.0.0 --port 8100 --p 8100 --livereload-p
ort 35729 --r 35729 --iscordovaserve --externalIpRequired --nobrowser

[17:26:32] build dev started …
[17:26:32] clean started …
[17:26:32] clean finished in 9 ms
[17:26:32] copy started …
[17:26:32] deeplinks started …
[17:26:32] deeplinks finished in 16 ms
[17:26:32] transpile started …
[17:26:36] transpile finished in 3.64 s
[17:26:36] preprocess started …
[17:26:36] preprocess finished in 1 ms
[17:26:36] webpack started …
[17:26:36] copy finished in 3.81 s
[17:26:42] webpack finished in 6.28 s
[17:26:42] sass started …
Without from option PostCSS could generate wrong source map and will not find
Browserslist config. Set it to CSS file path or to undefined to prevent this w
arning.
[17:26:43] sass finished in 1.24 s
[17:26:43] postprocess started …
[17:26:43] postprocess finished in 9 ms
[17:26:43] lint started …
[17:26:43] build dev finished in 11.33 s

cordova run android
Android Studio project detected

ANDROID_HOME=D:\Android_sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_171
studio
Subproject Path: CordovaLib
Subproject Path: app
[17:26:47] lint finished in 3.74 s

FAILURE: Build failed with an exception.

  • Where:
    Script ‘D:\IOnic_sample\myapp\platforms\android\CordovaLib\cordova.gradle’ line:
    68

  • What went wrong:
    A problem occurred evaluating project ‘:CordovaLib’.

No installed build tools found. Install the Android build tools version 19.1.0 o
r higher.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug
    option to get more log output.

  • Get more help at https://help.gradle.org

BUILD FAILED in 1s
(node:7540) UnhandledPromiseRejectionWarning: Error: cmd: Command failed with ex
it code 1 Error output:
FAILURE: Build failed with an exception.

  • Where:
    Script ‘D:\IOnic_sample\myapp\platforms\android\CordovaLib\cordova.gradle’ line:
    68

  • What went wrong:
    A problem occurred evaluating project ‘:CordovaLib’.

No installed build tools found. Install the Android build tools version 19.1.0
or higher.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug
    option to get more log output.

  • Get more help at https://help.gradle.org

BUILD FAILED in 1s
at ChildProcess.whenDone (D:\IOnic_sample\myapp\platforms\android\cordova\no
de_modules\cordova-common\src\superspawn.js:169:23)
at emitTwo (events.js:126:13)
at ChildProcess.emit (events.js:214:7)
at maybeClose (internal/child_process.js:925:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
(node:7540) 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:7540) [DEP0018] DeprecationWarning: Unhandled promise rejections are depre
cated. In the future, promise rejections that are not handled will terminate the
Node.js process with a non-zero exit code.

Your Cordova tooling seems to be out of date, which might be causing all kinds of problems.
You can read about how to figure out the current Cordova versions and how to update CLI, platforms and plugins here: https://ionic.zone/cordova/update

Your Ionic CLI is also really out of date. You should update with npm install -g ionic

I have update cordova and ionic
now ionic cordova build android is not working getting error
Help me out

ionic cordova platform add android now worked?

Then create a new topic for your new problem (and include your ionic info output).