使用Cordova Android项目时,出现错误-无法找到哈希字符串为“ android-26”的目标

时间:2018-09-26 17:23:02

标签: android cordova gradle

我收到以下错误,我相信我已经安装了所有用于构建针对android的东西。解决此错误的步骤是什么。我提供了android studio sdk管理器视图。

* 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 1s
(node:7005) UnhandledPromiseRejectionWarning: Error: /Users/SomeUser/Documents/workspaceOld/09042018110859/Company/platforms/android/gradlew: 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: /Users/SomeUser/Library/Android/sdk

-----

* 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 1s
    at ChildProcess.whenDone (/Users/SomeUser/Documents/workspaceOld/09042018110859/Company/platforms/android/cordova/node_modules/cordova-common/src/superspawn.js:169:23)
    at emitTwo (events.js:126:13)

当前信息:

SomeUser-MacBook-Pro:Primerica SomeUser$ npm -v
6.4.1
SomeUser-MacBook-Pro:Primerica SomeUser$ node -v
v8.11.1
SomeUser-MacBook-Pro:Primerica SomeUser$ cordova -v
8.0.0

在android sdk级别,这些目录存在:

./platforms/android-26
./system-images/android-26
./sources/android-26

enter image description here

他们在这里寻找什么

在/ Users / SomeUser / Library / Android / sdk中找不到带有哈希字符串“ android-26”的目标

2 个答案:

答案 0 :(得分:1)

找到附件链接以在PC中配置cordova

https://drive.google.com/file/d/1h6InPOJrinEJDTYWjpYDefyH-3g9IAQC/view

并确保

在SDK Manager上,请确保选中“显示软件包说明”框;那么您还应该为要安装的版本选择“ Google API”。

安装并检查。

希望这会对您有所帮助。谢谢

答案 1 :(得分:0)

您可能必须在local.properties文件中设置路径:

sdk.dir=/Users/SomeUser/Library/Android/sdk

并在用户个人资料(例如ANDROID_SDK_ROOT)中设置~/.bashrc

export ANDROID_HOME=/Users/SomeUser/Library/Android/sdk
export ANDROID_SDK_ROOT=$ANDROID_HOME