如何修复 cordova 中未安装 sdk 构建工具 android

How to fix no sdk build tools installed in cordova android

我在 mac 上设置 cordova 时遇到问题。

我收到此错误 No installed build tools found. Install the Android build tools version 30.0.3 or higher. 我已经使用 android studio 安装了构建工具。但是据我所知,当我 运行 'cordova build android'

时,cordova 没有使用它

我的构建日志

Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=undefined (DEPRECATED)
Using Android SDK: /opt/homebrew/Caskroom/android-sdk/4333796
Subproject Path: CordovaLib
Subproject Path: app

FAILURE: Build failed with an exception.

* Where:
Script '/Users/ad8kunle/app/platforms/android/CordovaLib/cordova.gradle' line: 69

* What went wrong:
A problem occurred evaluating script.
> No installed build tools found. Install the Android build tools version 30.0.3 or higher.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.1.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 1s

我的.bash-个人资料

export ANDROID_HOME=~/Library/Android/sdk
export ANDROID_SDK_ROOT=~/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
#THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!!
export SDKMAN_DIR="$HOME/.sdkman"
[[ -s "$HOME/.sdkman/bin/sdkman-init.sh" ]] && source "$HOME/.sdkman/bin/sdkman-init.sh"

我遇到了同样的问题,这对我的 mac 有效。

将路径添加到您的 ~/.bash_profile ( /users/ad8kunle/.bash_profile )

export ANDROID_HOME=/Android/sdk
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/tools:$PATH

退出终端并重新开始