Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ionic on Windows: Android SDK installed. Still get "Error: Please install Android target: "android-22"

I have managed to break my previously working version of the Ionic enviroment. For example: I download the demo project "sidemenu" and run "ionic platform add android" without any problem. When I try to run "ionic build" I get the following message:

$ ionic build
Running command: "c:\Program Files\nodejs\node.exe" h:\git\Absolut\hooks\after_p
repare\010_add_platform_class.js h:/git/myapp add to body class: platform-android
Running command: cmd "/s /c "h:\git\Absolut\platforms\android\cordova\build.bat"
"
[Error: Please install Android target: "android-22".

Hint: Open the SDK manager by running: c:\Users\nicsj\AppData\Local\Android\android-sdk\tools\android.BAT
You will require:
1. "SDK Platform" for android-22
2. "Android SDK Platform-tools (latest)
3. "Android SDK Build-tools" (latest)]
ERROR building one of the platforms: Error: cmd: Command failed with exit code 2

You may not have the required environment or OS to build this project
Error: cmd: Command failed with exit code 2
    at ChildProcess.whenDone (c:\Users\nicsj\AppData\Roaming\npm\node_modules\co
rdova\node_modules\cordova-lib\src\cordova\superspawn.js:134:23)
    at ChildProcess.emit (events.js:110:17)
    at maybeClose (child_process.js:1015:16)
    at Process.ChildProcess._handle.onexit (child_process.js:1087:5)

I don't understand what causes the error message since android-22 is already installed. I have the SDK Platform-tools and build-tools as well. They are on the PATH:

.../c/Program Files (x86)/Java/jdk1.7.0_71/bin:/c/Users/nicsj/AppData/Local/Android/android-sdk/tools:/c/Users/nicsj/AppData/Local/Android/android-sdk/build-tools/22.0.1:/c/Users/nicsj/AppData/Local/Android/android-sdk/platform-tools

Ionic setup:

Cordova CLI: 5.1.1
Gulp version:  CLI version 3.9.0
Gulp local:
Ionic CLI Version: 1.6.4
Ionic App Lib Version: 0.3.8
OS: Windows 7 SP1
Node Version: v0.12.5

Android SDK:

C:\Users\nicsj>android list targets
Available Android targets:
----------
id: 1 or "android-22"
     Name: Android 5.1.1
     Type: Platform
     API level: 22
     Revision: 2
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, W
XGA720, WXGA800, WXGA800-7in
 Tag/ABIs : no ABIs.
----------
id: 2 or "android-23"
     Name: Android 6.0
     Type: Platform
     API level: 23
     Revision: 1
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, W
XGA720, WXGA800, WXGA800-7in
 Tag/ABIs : no ABIs.

This problem is new and I don't know what caused it. Any advice on where I should look?

like image 620
veor Avatar asked Sep 07 '15 08:09

veor


1 Answers

First of all, sorry for my dummy english. I just had the same problem and I fix it changing the target:

# Project target.    
target=android-22 (I had set this to android-23)

This should be done in two files:

yourApp/platforms/android/project.properties    
yourApp/platforms/android/CordovaLib/project.properties

Also the manifest should be updated:

<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="23" />
like image 172
Thiago Delgado Avatar answered Sep 22 '22 20:09

Thiago Delgado