`ionic run android` throws error after updating the CLI and Android platform


#1

I updated the Ionic CLI and the Cordova Android (cordova platform update android@4.0.0).

Now when I try to run the app in android device, I am getting the following error:

Running command: /Users/saiy2k/projects/cordova/a1Mobile/hooks/after_prepare/010_add_platform_class.js /Users/saiy2k/projects/cordova/a1Mobile
add to body class: platform-android
Running command: /Users/saiy2k/projects/cordova/a1Mobile/hooks/after_prepare/020_remove_sass_from_platforms.js /Users/saiy2k/projects/cordova/a1Mobile
Running command: /Users/saiy2k/projects/cordova/a1Mobile/platforms/android/cordova/run 
ANDROID_HOME=/Users/saiy2k/projects/tools/sdk
JAVA_HOME=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
WARNING : No target specified, deploying to device 'HE4TFM6PGUWWPRQG'.
Running: /Users/saiy2k/projects/cordova/a1Mobile/platforms/android/gradlew cdvBuildDebug -b /Users/saiy2k/projects/cordova/a1Mobile/platforms/android/build.gradle -PcdvBuildArch=arm -Dorg.gradle.daemon=true

FAILURE: Build failed with an exception.

* Where:
Script '/Users/saiy2k/projects/cordova/a1Mobile/platforms/android/CordovaLib/cordova.gradle' line: 64

* What went wrong:
A problem occurred evaluating root project 'android'.
> No installed build tools found. Please 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.

BUILD FAILED

Total time: 2.261 secs

/Users/saiy2k/projects/cordova/a1Mobile/platforms/android/cordova/node_modules/q/q.js:126
                    throw e;
                          ^
Error code 1 for command: /Users/saiy2k/projects/cordova/a1Mobile/platforms/android/gradlew with args: cdvBuildDebug,-b,/Users/saiy2k/projects/cordova/a1Mobile/platforms/android/build.gradle,-PcdvBuildArch=arm,-Dorg.gradle.daemon=true
ERROR running one or more of the platforms: Error: /Users/saiy2k/projects/cordova/a1Mobile/platforms/android/cordova/run: Command failed with exit code 1
You may not have the required environment or OS to run this project

What could be the problem. Please help?

Update:
Reinstalled node/npm, cordova/ionic, but still same issue.

ionic info:
Cordova CLI: 5.1.1
Ionic Version: 1.0.0
Ionic CLI Version: 1.5.5
Ionic App Lib Version: 0.2.2
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Mac OS X Yosemite
Node Version: v0.12.4
Xcode version: Xcode 6.1.1 Build version 6A2008a

Update 2:


#2

Android Build Tools are not installed, or you don’t have have the right version installed. In this case version 19. Run “android” from your command-line to open the SDK manager, and add this version.


#3

I have Android SDK Build-tools version 20 installed. Or is it necessary to have exactly version 19. Let me try installing it too.


#4

And,did it work after installing version 19?


#5

Installed version 19. That error resolved, but had some other errors.

So created a new project from scratch, add the platforms, installed the plugins and moved the www folder and now it works :smile:

Thanks @tomkuipers.


#6

I have same problem and I tried to install many versions but same problem ;’(
@saiy2k @tomkuipers Please can you give me direct link to download appropriate version ?


#7

Hi. Don’t have direct link. Installed it through SDK Manager.


#8

@Shams Try to add it like this:


#9

@tomkuipers thank you very much … but still same issue.

Here is my SDK manager

What should I do ?


#10

Try uninstalling all Android SDK Build-tools except, v19.1


#11

Thank you … but when I uninstalling all android sdk Build-tools except v19.1 , this problem appears :frowning:

[Error: Please install Android target: “android-22”.

Hint: Open the SDK manager by running: f:\android_sdk\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

#12

I still have the same problem …

can anyone help me please …


#13

Not sure if this will help you but it solved my exact issue.

The problem is my Android SDK PATH changed after updating.

Please make sure your new android build tools are in ANDROID_HOME folder
which is /Users/saiy2k/projects/tools/sdk is your case.

The latest Android SDK is installed in C:\Users%USERNAME%\AppData\Local\Android\sdk\

If it need to be update, please change it in your System Environments.
If not, sorry, I can’t help.


#14

I had same problem. I uninstalled android studio, SDK tools and cordova and installed latest updates
now I can use
phonegap build android or
cordova build android or
ionic build android BUT with this error

Command finished with error code 0: cmd /s /c "C:\Users\IM\Desktop\myApp\platforms\android\gradlew.bat cdvBuildDebug -b C:\Users\IM\Desktop\myApp\platforms\android\build.gradle -Dorg.gradle.daemon=true -Dorg.gradle.jvmargs=-Xmx2048m -Pandroid.useDeprecatedNdk=true"

please HELP me