我在尝试Failed to find target with hash string 'android-26'
命令时遇到cordova run android
错误。
虽然我的Android>中有'android-26'文件夹平台文件夹(link)。我看到了很多问题,但我仍然没有找到适合我的解决方案。 我安装了Build-tools和API 26(参见see image,the Android SDK Manager中的图片)
这是我尝试使用Cordova构建的第一个应用程序。
以下是完整的跟踪:
Android Studio project detected
ANDROID_HOME=D:\Programmes\AndroidStudio
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_161
studio
Subproject Path: CordovaLib
Subproject Path: app
Starting a Gradle Daemon, 2 incompatible and 3 stopped Daemons could not be reused, use --status for details
publishNonDefault is deprecated and has no effect anymore. All variants are now published.
Checking the license for package Android SDK Build-Tools 27.0.3 in D:\Programmes\AndroidStudio\licenses
License for package Android SDK Build-Tools 27.0.3 accepted.
Preparing "Install Android SDK Build-Tools 27.0.3 (revision: 27.0.3)".
"Install Android SDK Build-Tools 27.0.3 (revision: 27.0.3)" ready.
Installing Android SDK Build-Tools 27.0.3 in D:\Programmes\AndroidStudio\build-tools\27.0.3
"Install Android SDK Build-Tools 27.0.3 (revision: 27.0.3)" complete.
"Install Android SDK Build-Tools 27.0.3 (revision: 27.0.3)" finished.
Checking the license for package Android SDK Platform 26 in D:\Programmes\AndroidStudio\licenses
License for package Android SDK Platform 26 accepted.
Preparing "Install Android SDK Platform 26 (revision: 2)".
"Install Android SDK Platform 26 (revision: 2)" ready.
Installing Android SDK Platform 26 in D:\Programmes\AndroidStudio\platforms\android-26
"Install Android SDK Platform 26 (revision: 2)" complete.
"Install Android SDK Platform 26 (revision: 2)" finished.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':CordovaLib'.
Failed to find target with hash string 'android-26' in: D:\Programmes\AndroidStudio
* 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 7m 14s
(node:8356) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':CordovaLib'.
Failed to find target with hash string 'android-26' in: D:\Programmes\AndroidStudio
* 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 7m 14s
答案 0 :(得分:1)
问题已解决:我在计算机上的两个不同位置安装了两个SDK。我将environnement变量更改为另一个变量,现在它可以正常工作。