“cordova build android” 失败,显示”没有找到已安装的构建工具”。

huangapple go评论50阅读模式
英文:

"cordova build android" fails with "no installed build tools found"

问题

我已经到处寻找这个问题的解决方法。

https://stackoverflow.com/questions/54447081/ionic-cordova-build-android-no-installed-build-tools-found 没有起作用

https://stackoverflow.com/questions/74952540/cordova-build-android-failed-with-exception 是一个荒谬的回答。当然,Android Studio 已经安装了!

https://stackoverflow.com/questions/28789556/android-studio-sdk-tools-directory-is-missing 我已经做了这个。$ANDROID_SDK_ROOT/tools 文件夹现在存在了,但这并没有解决我的问题。

我尝试了这里给出的建议:https://stackoverflow.com/questions/54447081/ionic-cordova-build-android-no-installed-build-tools-found 当我运行sdkmanager packages "build-tools;30.0.3"时,只得到了来自 SDK 管理器的"找不到包 'packages'"的错误消息。

我在这里找到了一些信息:https://stackoverflow.com/questions/45748183/android-sdk-manager-does-not-exist,并安装了他们说要安装的所有东西,包括过时的包。但仍然没有运气。

这是我的路径:
/opt/homebrew/bin:/Users/lmacneill/.sdkman/candidates/java/current/bin:/Users/lmacneill/.sdkman/candidates/gradle/current/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Users/lmacneill/CordovaProjects/gamapp/node_modules/.bin:/Users/lmacneill/Library/Android/sdk/tools:/Users/lmacneill/Library/Android/sdk/build-tools:/Users/lmacneill/Library/Android/sdk/platform-tools

这是我的 Android Studio SDK Platforms 屏幕:
https://i.stack.imgur.com/2e5YI.png

这是我的 Android Studio SDK Tools 屏幕:
https://i.stack.imgur.com/btLIR.png

(与此帖子无关,但非常奇怪 - 它告诉我我需要10个声誉才能发布图像,但我有661个声誉。为什么会这样?因此,我提供了图像的链接而不是实际的图像。)

那么为什么找不到这些工具?!!!! 我已经按照每个人的建议做了一切,但它仍然不起作用!!!

这太荒谬了!!!肯定有人知道答案?

英文:

I have looked EVERYWHERE for the solution to this.

https://stackoverflow.com/questions/54447081/ionic-cordova-build-android-no-installed-build-tools-found did not work

https://stackoverflow.com/questions/74952540/cordova-build-android-failed-with-exception was a ridiculous non-answer. OF COURSE Android Studio is installed!!!

https://stackoverflow.com/questions/28789556/android-studio-sdk-tools-directory-is-missing I did this. The $ANDROID_SDK_ROOT/tools folder now exists, but that didn't solve my problem.

I tried the advice given here: https://stackoverflow.com/questions/54447081/ionic-cordova-build-android-no-installed-build-tools-found and all I get when I run sdkmanager packages "build-tools;30.0.3" is "failed to find package 'packages'" from the SDK Manager.

I looked here: https://stackoverflow.com/questions/45748183/android-sdk-manager-does-not-exist and installed ALL the stuff they said to install -- including the obsolete packages. And still no luck.

Here's my path:
/opt/homebrew/bin:/Users/lmacneill/.sdkman/candidates/java/current/bin:/Users/lmacneill/.sdkman/candidates/gradle/current/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Users/lmacneill/CordovaProjects/gamapp/node_modules/.bin:/Users/lmacneill/Library/Android/sdk/tools:/Users/lmacneill/Library/Android/sdk/build-tools:/Users/lmacneill/Library/Android/sdk/platform-tools

Here's my Android Studio SDK Platforms screen:
https://i.stack.imgur.com/2e5YI.png

And here's my Android Studio SDK Tools screen:
https://i.stack.imgur.com/btLIR.png

(Unrelated to this post, but very weird -- it told me I needed 10 reputation to post images, yet I have 661 reputation. Why did it do that? Hence the link to my images instead of the actual images.)

SO WHY CAN THE TOOLS NOT BE FOUND?!!!!!!. I've done EVERYTHING that EVERYONE has suggested, and STILL IT DOESN'T WORK!!!!

This is ridiculous!!!! Surely someone must know the answer?

答案1

得分: 1

$ANDROID_SDK_ROOT/build-tools文件夹中,有一个名为33.0.2的文件夹。因此,在我的.zshrc文件中,我需要将$ANDROID_SDK_ROOT/build-tools替换为$ANDROID_SDK_ROOT/build-tools/33.0.2

然后,cordova build android终于可以正常工作了!

顺便说一下,我是在终于成功使用sdkmanager安装build-tools;30.0.3时才弄清楚的,你必须使用sdkmanager "build-tools;30.0.3"命令,而不是sdkmanager packages "build-tools;30.0.3"命令。也许带有'packages'部分的命令适用于旧版本的sdkmanager?但现在明显不起作用。总之,一旦我看到它在$ANDROID_SDK_ROOT/build-tools中创建了一个新文件夹,我终于意识到仅仅将$ANDROID_SDK_ROOT/build-tools添加到路径中是不够的。你还必须包括版本文件夹。

ANDROID!!! 你们应该让这个变得更容易!!!安装ANDROID STUDIO应该自动完成所有这些步骤!!!

英文:

Well... I FINALLY figured it out...

In the $ANDROID_SDK_ROOT/build-tools folder, there was a 33.0.2 folder. So in my .zshrc file, instead of adding $ANDROID_SDK_ROOT/build-tools to the path, I needed to add $ANDROID_SDK_ROOT/build-tools/33.0.2 to the path.

Then cordova build android FINALLY worked!!!

BTW, I figured this out when I finally got sdkmanager to install the build-tools;30.0.3 -- you have to use sdkmanager "build-tools;30.0.3" command, NOT the sdkmanager packages "build-tools;30.0.3" command. Maybe the command with the 'packages' bit worked for an older version of sdkmanager? But it definitely doesn't work now. Anyway, once I saw that it had created a new folder in $ANDROID_SDK_ROOT/build-tools, I finally realized that exporting only $ANDROID_SDK_ROOT/build-tools in the path wasn't enough. You have to include the version folder in there as well.

ANDROID!!! Y'ALL SHOULD MAKE THIS EASIER!!!! INSTALLING ANDROID STUDIO SHOULD DO ALL OF THIS STUFF AUTOMATICALLY!!!!!

huangapple
  • 本文由 发表于 2023年2月10日 03:45:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/75403696.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定