cordova requirements issue , android target not installed
Asked Answered
B

7

21

I am trying to install Cordova on windows 7. I am following this tutorial : https://www.tutorialspoint.com/cordova/cordova_first_application.htm

while I run cordova requirements, it says android target is not intalled and set the ANDROID_HOME environment variable

I:\CordovaProject\hello>cordova requirements
Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: not installed
Android SDK not found. Make sure that it is installed. If it is not at the 
default location, set the ANDROID_HOME environment variable.
Gradle: installed
Error: Some of requirements check failed

I:\CordovaProject\hello>echo %ANDROID_HOME%
C:\Users\user\AppData\Local\Android\sdk

as you can see in the image 1, when I echo ANDROID_HOME it is set to proper location. I am not able to resolve this error. kindly help me with this

path has these : %ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools

I have downloaded android-25 in android studio

and project properties file has android target set to : android-25 both in I:\CordovaProject\hello\platforms\android\CordovaLib\project.properties
I:\CordovaProject\hello\platforms\android\project.properties

and when i run cordova build android i get following error

BUILD FAILED

Total time: 31.807 secs
Error: cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'android'.
 > Could not resolve all dependencies for configuration ':classpath'.
 > Could not download uast.jar (com.android.tools.external.com-
 intellij:uast:145.597.3)
  > Could not get resource 'https://jcenter.bintray.com/com/android/tools/ex
 ternal/com-intellij/uast/145.597.3/uast-145.597.3.jar'.
     > Could not GET 'https://jcenter.bintray.com/com/android/tools/external
  /com-intellij/uast/145.597.3/uast-145.597.3.jar'.
        > akamai.bintray.com

  * Try:
   Run with --stacktrace option to get the stack trace. Run with --info or -
   -debug   option to get more log output.
Blitzkrieg answered 17/4, 2017 at 9:37 Comment(0)
D
9

For SDK 21 ("android-21")

$ cordova platform remove android
$ cordova platform add [email protected]

For SDK 22 (Android 4.1.1, "android-22")

$ cordova platform remove android
$ cordova platform add [email protected]
Depressor answered 11/12, 2017 at 20:42 Comment(1)
its platform singular, not plural.Dahlberg
T
7

I found the same issue and fix it!

Its related to Java path in JAVA_HOME and Path Variable should contain the same path with Android Studio (JRE folder). You may found this info in Android Studio, SDK Location.

After Change my Path and JAVA_HOME variable (go to control panel, system and security, system, environment variable) update Path and JAVA_HOME variable to C:\Program Files\Android\Android Studio\jre.

More detail... JAVA_HOME contains C:\Program Files\Android\Android Studio\jre and Path contains C:\Program Files\Android\Android Studio\jre\bin

checking requirements all good !

cordova requirements

Touchstone answered 17/1, 2019 at 22:7 Comment(1)
Totally different from evothings.com/doc/build/…. Why?Cralg
K
2

You should check the build target specified in the Manifest and then cross check if you have the same target sdk installed using sdk manager in android-studio.

Note: The line you should be looking for will be:

<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="22" />
Katz answered 17/4, 2017 at 9:46 Comment(1)
This file is located in platforms\android\CordovaLib\AndroidManifest.xml correct ?Pyrogallol
P
2

An easy and quick answer:

if your Env variables are not set correctly you will see any possible error, most errors will be solved if you set (correctly) :

(WARNING: I assume that you already have JAVA JDK set)

 ANDROID_HOME: C:\Users\marwe\AppData\Local\Android\Sdk

 ANDROID_SDK_ROOT: C:\Users\marwe\AppData\Local\Android\Sdk

You can change the path according to your machine, you can find the Android SDK path by opening Android Studio like shown in this picture:

enter image description here

Peek answered 9/4, 2020 at 13:24 Comment(0)
J
1

You may also try As mentioned here https://mcmap.net/q/660778/-cordova-requirements-error-quot-android-target-not-installed-quot try installing JDK version less than 9, like JDK8

Johnston answered 30/4, 2018 at 10:1 Comment(0)
I
0

Linux (Xubuntu):
I have android-studio installed in /opt/google/android-studio;
but the sdk folder is trully installed in /home/{computerName}/Android/Sdk;
Error in Android target install was a PATH problem
Remove the misleading PATH and reinserting the correct one was the solution:
at the end of file in .bashrc (/home/{computerName}/.bashrc)

PATH=$(REMOVE_PART="/opt/google/android-sdk/" sh -c 'echo ":$PATH:" | sed "s@:$REMOVE_PART:@:@g;s@^:\(.*\):\$@\1@"')
export ANDROID_SDK_ROOT="/home/{computerName}/Android/Sdk"
export ANDROID_HOME= "/home/{computerName}/Android/Sdk"
export PATH=${PATH}:$ANDROID_SDK_ROOT/tools:$ANDROID_SDK_ROOT/platform-tools 

{computerName} to be substituted with your computer name.
checked if there was any previous export statements that would conflict;
closed the terminal and reopened it. called env in terminal:

env

to check if the .bashrc was correctly loaded;
after confirmation, re-runned cordova requirements;

cordova requirements

this fix in the path also solved the issue of "not finding platform tools" error in cordova run command.

Incurable answered 7/1, 2020 at 9:36 Comment(0)
V
0

OpenJDK 8 fixed this for me on Windows 11.

C:\Users\16515\Desktop\prj\cordova\hello>java -version
openjdk version "1.8.0_352-352"
OpenJDK Runtime Environment (build 1.8.0_352-352-b08)
OpenJDK 64-Bit Server VM (build 25.352-b08, mixed mode)

C:\Users\16515\Desktop\prj\cordova\hello>cordova requirements

Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: installed android-31,android-30,android-29,android-28,android-27,android-26
Gradle: installed C:\Program Files\gradle-7.5.1\bin\gradle.BAT
Verla answered 16/11, 2022 at 17:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.