Please note: attempted to open JIRA issue for this, but was unable to add a bug 
to "Apache Cordova" project in the JIRA site for Apache 
(https://issues.apache.org/jira/projects/CB).

Attempting to build the "HelloWorld" Cordova app fails with the error:

```
FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Failed to find target with hash string '27' in: C:\development\AndroidSDK
```

This seems to be pulled from "/platforms/android/CordovaLib/project.properties" 
file, "target=android-27" because changing to "target=aandroid-27" then shows 
the error "Failed to find target with hash string 'aandroid-27'". Changing back 
to "target=android-27" again and running "cordova build android" shows the 
error for value "27" **without** the "android-" part of the string. 

Since the Android SDK puts the versions in folders such as "android-27"; it is 
clear that it cannot find that directory. 

Since this is vanilla Cordova with only the base requirements from the 
documentation and the "HelloWorld" app created by Cordova, there are no third 
party extensions, etc. or other issues that should be causing this to throw 
this error.


The following are the steps that were taken to download and install 
requirements.
* Loaded Java JDK/JRK 1.8.0_181 from Oracle for 64-bit.
** "c:\Java\JDK1.8.0_181"
** "c:\Java\JRE1.8.0_181"
** JAVA_HOME was updated to "c:\Java\JRE1.8.0_181"
* Loaded latest Android Studio for 64-bit.
** Loaded all Android SDK's from 19-28 (28 was already installed)
** "c:\development\androidSDK\..." as there was a message about dirs with 
spaces.
** ANDROID_HOME was updated to "C:\development\AndroidSDK"
** Loaded through the Android Studio File -> Settings -> Appearance & Behavior 
-> System Settings -> Android SDK screen.

Then Cordova was loaded.
* Loaded latest Cordova (npm install cordova -g) from command line.

Then the steps to create the "HelloWorld" app were followed from the 
documentation (link in description). NOTE: a console screen print is attached 
of the commands and results at the end of this issue.
* Created new app "HelloWorld" according to 
https://cordova.apache.org/docs/en/latest/guide/cli/index.html in new, blank 
directory (c:\test).
* Entered "hello" directory.
* Ran "cordova platform add android" - installed android platform.
* Ran "cordova requirements"
* Ran "cordova build android"

PowerShell screen commands and responses:
```
PS C:\> cd development
PS C:\development> cd github
PS C:\development\github> mkdir cordova-test


    Directory: C:\development\github


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----        10/4/2018   2:01 PM                cordova-test


PS C:\development\github> cd cordova-test
PS C:\development\github\cordova-test> cordova create hello com.example.hello 
HelloWorld
Creating a new cordova project.
PS C:\development\github\cordova-test> dir


    Directory: C:\development\github\cordova-test


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----        10/4/2018   2:01 PM                hello


PS C:\development\github\cordova-test> cd hello
PS C:\development\github\cordova-test\hello> dir


    Directory: C:\development\github\cordova-test\hello


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----        10/4/2018   2:01 PM                hooks
d-----        10/4/2018   2:01 PM                platforms
d-----        10/4/2018   2:01 PM                plugins
d-----        10/4/2018   2:01 PM                res
d-----        10/4/2018   2:01 PM                www
-a----        10/4/2018   2:01 PM             17 .npmignore
-a----        10/4/2018   2:01 PM            984 config.xml
-a----        10/4/2018   2:01 PM            366 package.json


PS C:\development\github\cordova-test\hello> cordova platform add android
Using cordova-fetch for cordova-android@~7.1.1
Adding android project...
Creating Cordova project for the Android platform:
        Path: platforms\android
        Package: com.example.hello
        Name: HelloWorld
        Activity: MainActivity
        Android target: android-27
Android project created with [email protected]
Android Studio project detected
Android Studio project detected
Discovered plugin "cordova-plugin-whitelist" in config.xml. Adding it to the 
project
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.

Adding cordova-plugin-whitelist to package.json
Saved plugin info for "cordova-plugin-whitelist" to config.xml
--save flag or autosave detected
Saving android@~7.1.1 into config.xml file ...
PS C:\development\github\cordova-test\hello> cordova requirements
Android Studio project detected

Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: installed 
android-28,android-27,android-26,android-25,android-24,android-23,android-22,android-21,android-20,android-19
Gradle: installed C:\Program Files\Android\Android 
Studio\gradle\gradle-4.6\bin\gradle
PS C:\development\github\cordova-test\hello> cordova build android
Android Studio project detected
ANDROID_HOME=C:\development\AndroidSDK
JAVA_HOME=C:\Java\jdk1.8.0_181
studio
Starting a Gradle Daemon, 2 incompatible Daemons could not be reused, use 
--status for details

BUILD SUCCESSFUL in 10s
1 actionable task: 1 executed
Subproject Path: CordovaLib
Subproject Path: app
publishNonDefault is deprecated and has no effect anymore. All variants are now 
published.
The Task.leftShift(Closure) method has been deprecated and is scheduled to be 
removed in Gradle 5.0. Please use Task.doLast(Action) instead.
        at 
build_648mpip0kozgkz3v7ai57q9rz.run(C:\development\github\cordova-test\hello\platforms\android\app\build.gradle:143)

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Failed to find target with hash string '27' in: C:\development\AndroidSDK

* 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 5s
cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Failed to find target with hash string '27' in: C:\development\AndroidSDK

* 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 5s
PS C:\development\github\cordova-test\hello>
```

[ Full content available at: 
https://github.com/apache/cordova-android/issues/509 ]
This message was relayed via gitbox.apache.org for [email protected]

Reply via email to