【问题标题】:Failed to find target with hash string 'android-26' with Cordova无法使用 Cordova 找到带有哈希字符串“android-26”的目标
【发布时间】:2018-03-26 11:24:35
【问题描述】:

我在尝试cordova run android 命令时一直出现Failed to find target with hash string 'android-26' 错误。

虽然我的 Android > 平台文件夹 (see image) 中有一个“android-26”文件夹。我看到了很多问题,但我仍然没有找到适合我的解决方案。 我已经安装了 Build-tools 和 API 26(参见the Android SDK ManagerAndroid SDK Manager in Android Studio 的图片)

这是我尝试使用 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

【问题讨论】:

  • 感谢您的回答!但正如您在 Android SDK 管理器的图像中看到的那样,android-26 似乎已正确安装。当我使用 Cordova 时,我没有帖子中提到的相同的“build.gradle”文件。我在 android 文件夹中有一个“build.gradle”文件,将 defaultTargetSdkVersiondefaultCompileSdkVersion 设置为 26。

标签: android cordova


【解决方案1】:

问题已解决:我在计算机的两个不同位置安装了两个 SDK。我将环境变量更改为另一个,现在它可以工作了。

【讨论】:

    猜你喜欢
    • 2023-04-03
    • 1970-01-01
    • 2018-04-04
    • 2018-11-23
    • 1970-01-01
    • 2016-06-26
    • 2017-03-20
    • 2023-03-19
    • 1970-01-01
    相关资源
    最近更新 更多