I just updated cordova + ionic in my app, after that i installed successfully Android-SDK v22 via Android SDK manager.
But after the running command:
cordova build android
I always get the following message:
Running command: /Users/peter/workspace/myapp/platforms/android/cordova/build
[Error: Please install Android target: "android-21".
Hint: Open the SDK manager by running: /Users/peter/adt-bundle-mac/sdk/tools/android
You will require:
1. "SDK Platform" for android-21
2. "Android SDK Platform-tools (latest)
3. "Android SDK Build-tools" (latest)]
ERROR building one of the platforms: Error: /Users/peter/workspace/myapp/platforms/android/cordova/build: Command failed with exit code 2
You may not have the required environment or OS to build this project
Error: /Users/peter/workspace/myapp/platforms/android/cordova/build: Command failed with exit code 2
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1008:16)
at Process.ChildProcess._handle.onexit (child_process.js:1080:5)
I tried also
cordova platform rm android
cordova platform add android
But with the same result:
I tried to find a few hours any working solution, but with luck.
Thanks for any advice.
System information:
OS: Mac OS X Yosemite
Node Version: v0.12.0
Cordova CLI: 4.3.0
Ionic Version: 0.9.27
Ionic CLI Version: 1.3.18
Xcode version: Xcode 6.2 Build version 6C131e
ios-sim version: 3.1.1
ios-deploy version: 1.4.0
I just had the same problem.
I had to change the target:
# Project target.
target=android-22
This should be done in two files:
myApp/platforms/android/project.properties
myApp/platforms/android/CordovaLib/project.properties
Also the manifest should be updated:
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="22" />
Follow these steps.
1) Type android on command line.(Make sure ANDROID_HOME and PATH are set properly)
2) Select API 21 from the populated list.
3) Click install packages.
4) Type android avd on command line.
5) Set API level and other config.
6) Now type ionic build android.
many times the problem is that not is configurated the path environment variable ANDRIOD_HOME.
Take a look
%ANDROID_HOME% = C:\Program Files (x86)\Android\android-sdk
In Path:
%ANDROID_HOME%\tools;
%ANDROID_HOME%\platform-tools;
In my case it was the path to my SDK folder that was causing this error.
C:\Users\username\AppData\Local\Android\android-sdk
changed to
C:\Users\username\AppData\Local\Android\sdk
I have been having the same problem in windows. It appeared that when I was running the SDK Manager you have to select "Run as Administrator" otherwise it denies permission to install certain files, on of them being "ANDROID-22"
Here is the the link I found to resolve this issue:
android sdk manger not updating
Open Android SDK Manager, and check whether the target version exists, Install if not exists.
Make sure your project path doesn't consist spaces.
I face the same problem asking me to install the target android platform when build. I have triple confirm my android sdk path, jdk path and various setting in path but still getting the same error. Finally, the problem resolved by simply renamed(removed spaces) the folder that store my Cordova project. For example : "C:\Cordova & Phonegap Sample\MyCordovaApp" to "C:\Cordova_Sample\MyCordova".
another way to fulfill an android target requirement would be:
$sdkmanager "platforms;android-21"
For those who run Visual Studio and have Mobile Development with JavaScript installed,
you can run C:\ProgramData\Microsoft\AndroidSDK\25\tools\android.BAT and then proceed to install Android 5.0.1 or the relevant API.
Related
I'm a newcomer to the Cordova world, so I'm attempting to build and run my first app. To do so, I'm following the steps set out in the official Cordova page but I'm getting an error at the build stage.
Apparently, the android platform is added successfully:
D:\Users\user\workspace\cordova\helloworld>cordova platform add android
Using cordova-fetch for cordova-android#~6.3.0
Adding android project...
Creating Cordova project for the Android platform:
Path: platforms\android
Package: com.example.helloworld
Name: HelloWorld
Activity: MainActivity
Android target: android-26
Subproject Path: CordovaLib
Android project created with cordova-android#6.3.0
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.
--save flag or autosave detected
Saving android#~6.3.0 into config.xml file ...
But when I check if the pre-requisites for the build stage are met, I get the following error:
D:\Users\user\workspace\cordova\helloworld>cordova requirements
Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: not installed
cmd: Command failed with exit code 1 Error output: "avdmanager" no se reconoce como un comando interno o externo, programa o archivo por lotes ejecutable.
Gradle: installed C:\Program Files\Gradle\gradle-4.3.1\bin\gradle
Error: Some of requirements check failed
I don't just understand how is it possible no Android target is installed as long as the cordova platform add android command worked successfully. What am i doing wrong?
I've got the following tools installed (Windows 7 x64):
JDK 1.8.0
Android SDK 25.2.5
Gradle 4.3.1
Node 8.9.1
Cordova 7.1.0
I think the environment variables are set ok:
ANDROID_HOME=C:\Program Files (x86)\Android\android-sdk
GRADLE_PATH=C:\Program Files\Gradle\gradle-4.3.1
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_152
Path= ... ; C:\Program Files\nodejs\;
D:\Users\user\AppData\Roaming\npm;
C:\Program Files\Java\jdk1.8.0_152\bin;
C:\Program Files (x86)\Android\android-sdk\platform-tools;
C:\Program Files (x86)\Android\android-sdk\tools;
C:\Program Files\Gradle\gradle-4.3.1\bin
I'd like to say that I didn't install Android Studio as I prefer to use eclipse+ADT plugin. To install the Android SDK tool I got from the Internet an installer .exe (version 24.4.1) which got updated automatically on first run. Current version of Android SDK, and as I said, is 25.2.5. From the Android SDK Manager I installed API levels 21 - 26, which I can see within the ANDROID_HOME\platforms (android-21, android-22, ..., android-26 folders).
Any explanation about what is happening would be appreciated.
Thanks.
Try changing the target api version in manifest file, project. properties in platform folder (android)and project.properties in Cordovalib folder
I am having a really annoying issue when I try to run my cordova project on Android.
When I run the command
$ cordova platform add android
it fails with following error:
Error: Failed to run "android". Make sure you have the latest Android SDK installed, and that the "android" command (inside the tools/ folder) is added to your PATH.
However, I do have the android command in my PATH, and I do have an Android SDK installed:
$ echo $PATH
/home/<user>/code/android-studio/gradle/gradle-3.2/bin:/home/<user>/Android/Sdk/tools:/home/<user>/Android/Sdk/platform-tools:<...>
I can even run the android command in the shell, and list the installed SDKs:
$ android list target
*************************************************************************
The "android" command is deprecated.
For manual SDK, AVD, and project management, please use Android Studio.
For command-line tools, use tools/bin/sdkmanager and tools/bin/avdmanager
*************************************************************************
Running /home/arthur/Android/Sdk/tools/bin/avdmanager list target
Available Android targets:
----------
id: 1 or "android-26"
Name: Android API 26
Type: Platform
API level: 26
Revision: 2
My cordova version is as follows:
$ cordova --version
4.0.0
It has to be this version otherwise this project won't build.
What am I missing here? What do I do to cordova to recognize that the android command is actually available?
Thanks!
Which cordova-android version do you have?. Try to run this command
cordova platforms android
Depends which version you have, you need to download an android sdk. For example, cordova-android version 6.2.6 supports Android SDK Tools v26. See this link. I suspect that you have an older version of cordova-android, you'll need to install a minor sdk.
I'm struggling with my phonegap setup and building my first app.
I created a hello1 project. I added the android project
Platform android already added
Now when I run the cordova build, I get the error -
Error: Please install Android target: "android-22"
I do not have android-22. I do have android-19. I want my project to be built with android-19. How can I make that happen?
I had android-22 which I uninstalled (for fixing a bigger problem). I do not understand which file should I be making a change in for this to work.
The project.properties in the project comes after this step and it automatically contains the target as android-22.
I have added my env variables correctly.
C:\Users\user\android-sdks\platform-tools;C:\Users\user\android-sdks\tools
It doesn't help. This is just part of a bigger problem that I'm trying to debug. Please help.
For SDK 21 ("android-21")
$ cordova platforms remove android
$ cordova platforms add android#3.7.1
For SDK 22 (Android 4.1.1, "android-22")
$ cordova platforms remove android
$ cordova platforms add android#4.1.1
More info: https://cordova.apache.org/announcements/2015/07/21/cordova-android-4.1.0.html
Change these two. I din't try it for lower versions but this worked for me in upper versions
target=android-22<br>
This should be changed in two files like below:
target=android-19<br>
Location of the two files:
myApp/platforms/android/project.properties
myApp/platforms/android/CordovaLib/project.properties
I am using cordova 3.5.0 which by default has target sdk as 19.
You can install cordova 3.5.0 using
npm install -g cordova#3.5.0-0.2.6
For other versions of Cordova if you want to manually edit it you have to change this in AndroidManifest.xml file present in yourapplication/platfomrs/android.
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="19" />
My problem got solved after installing SDK Platform of Andriod 5.1.1 (API 22) from Andriod Manager.
Steps:
$ /Users/username/Library/Android/sdk/tools/android
Install Android 5.1.1 (API 22)
$ cordova platforms add android#4.4.2
$ cordova build --release android
It works for me.
$ cordova platforms remove android
$ cordova platforms add android#3.7.1
I try to get this working and it's driving me nuts:
$ cordova platform add android
The output is:
Creating android project...
/Users/doekewartena/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:126
throw e;
^
Error: Please install Android target 19 (the Android newest SDK). Make sure you have the latest Android tools installed as well. Run "android" from your command-line to install/update any missing SDKs or tools.
at /Users/doekewartena/.cordova/lib/android/cordova/3.5.0/bin/lib/check_reqs.js:80:29
at _fulfilled (/Users/doekewartena/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:798:54)
at self.promiseDispatch.done (/Users/doekewartena/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:827:30)
at Promise.promise.promiseDispatch (/Users/doekewartena/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:760:13)
at /Users/doekewartena/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:574:44
at flush (/Users/doekewartena/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:419:13)
Error: /Users/doekewartena/.cordova/lib/android/cordova/3.5.0/bin/create: Command failed with exit code 8
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:135:23)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:755:16)
at Process.ChildProcess._handle.onexit (child_process.js:822:5)
If did run the command android this are all the things I installed:
I also did:
open ~/.bash_profile
And added:
export PATH=${PATH}:/Users/doekewartena/Documents/adt-bundle-mac-x86_64-20140702/sdk/platform-tools:/Users/doekewartena/Documents/adt-bundle-mac-x86_64-20140702/sdk/tools
But it doesn't help :(
Could someone help.
Android SDK is not your target Android version. Target Android version 19 is the API level for android Kitkat.So in you SDK manager check if you have Android 4.4.2(API 19) installed. If you want your target API version to be different then change it in ANdroidManifest.xml
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="18" />
Edit these lines. Here android:targetSdkVersion is your Android version that you are targeting.
Went into the SDK Manager (typing android into the terminal, assuming it's in your file path)
Selected box next to Android 4.4.2 (API 19)
Clicked button Install 8 packages
Ran original command (in this example cordova platform add android, although it could be ionic platform add android, depending on what you're working with)
I too was getting the same error 19. I have no idea about AndroidManifest.xml and where it is supposed to be.
In my case, I fixed the error by running the 'android' command from the console, opening the Android 4.4.2 (API19) tree and installing the SDK Platform.
After this was installed the cordova platform add android command worked as desired.
Further to this I had to install a few other elements of API19 to be able to create an android emulator:
ARM EABI v7a System Image
Intel x86 Atom System Image
Google APIs (x86 System Image)
Google APIs (ARM System Image)
I could then create an emulator based on API19 using the Android Virtual Device (AVD) Manager that is included in the android SDK bundle.
I also had to change project.properties in the same directory
target=android-19
android.library.reference.1=CordovaLib
Here is documentation on how you set up an AndroidManifest.xml document.
Every app should have one.
http://developer.android.com/guide/topics/manifest/manifest-intro.html
If your having issues installing the package, ensure you are running 'Android Central' as an administrator... took me 30 mins to work it out!!
How do I recover from this error?
[Error: The command android failed. Make sure you have the latest Android SDK
installed, and the android command (inside the tools/ folder) added to your path. Output: ]
You just need to install the Latest version of Android i.e 4.3/4.4
Go to SDK Manager and install the latest SDK Platform.
And try run the command again.
cordova platform add android