Cordova run android fails

Hi,

the cmd cordova run android fails with this message:

Android Studio project detected
ANDROID_HOME=C:\Users\LS\AppData\Local\Android\Sdk\tools
JAVA_HOME=C:\PROGRA~1\Java\jdk1.8.0_161
studio
Subproject Path: CordovaLib
Subproject Path: app

FAILURE: Build failed with an exception.

* Where:
Script 'C:\Users\LS\Desktop\ionic\ionic_1\cutePuppyPics\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.

ionic cordova requirements

returns:

Android Studio project detected


Requirements check results for android:

Java JDK: installed 1.8.0
Android SDK: installed true
Android target: installed android-27,android-26,android-25,android-24,android-22,android-21
Gradle: installed C:\Program Files\Android\Android Studio\gradle\gradle-4.1\bin\gradle

Requirements check results for ios:
Apple macOS: not installed
Cordova tooling for iOS requires Apple macOS
(node:1436) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): CordovaError: Some of requirements check failed
(node:1436) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

according cordova requirements

everything is fine, too:

Android Studio project detected

Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: installed android-27,android-26,android-25,android-24,android-22,android-21
Gradle: installed C:\Program Files\Android\Android Studio\gradle\gradle-4.1\bin\gradle

Requirements check results for ios:
Apple macOS: not installed
Cordova tooling for iOS requires Apple macOS
(node:11480) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): CordovaError: Some of requirements check failed
(node:11480) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

What could be the issue?

What is your ionic info output?

cli packages: (C:\Users\LS\AppData\Roaming\npm\node_modules)

    @ionic/cli-utils  : 1.19.1
    ionic (Ionic CLI) : 3.19.1

global packages:

    cordova (Cordova CLI) : 8.0.0

local packages:

    @ionic/app-scripts : 3.1.8
    Cordova Platforms  : none
    Ionic Framework    : ionic-angular 3.9.2

System:

    Node : v8.9.3
    npm  : 5.6.0
    OS   : Windows 10

Environment Variables:

    ANDROID_HOME : C:\Users\LS\AppData\Local\Android\Sdk\tools

Misc:

    backend : pro


That doesn’t look right, does it?

yep. I have added android as platform and still get this error:

PS E:\Work\apps\app_1\cutePuppyPics> cordova run android
Android Studio project detected
ANDROID_HOME=C:\Users\LS\AppData\Local\Android\Sdk\tools
JAVA_HOME=C:\PROGRA~1\Java\jdk1.8.0_161
studio
Subproject Path: CordovaLib
Subproject Path: app

FAILURE: Build failed with an exception.

* Where:
Script 'E:\Work\apps\app_1\cutePuppyPics\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 4s
(node:11644) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* Where:
Script 'E:\Work\apps\app_1\cutePuppyPics\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 4s
(node:11644) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
PS E:\Work\apps\app_1\cutePuppyPics>

Could it be possible, that my android build tools are too new?
I had similar issues with the latest version of JDK.

What version of cordova-android are you using?

(You should look on Github if there is an issue for ionic-cli already about the missing platforms or create one if not)

Where can I see the version?

Update: The function that returned the buildToolsDir in cordova.grade on 43 looked into the wrong directory.
I hardcoded it for now:

 def buildToolsDir = new File( "C:/Users/LS/AppData/Local/Android/Sdk/", "build-tools")
    //  throw new RuntimeException(
    //       "----------->" + buildToolsDir
    //  )