Cordova Cli -未找到可用的Android构建工具

z9smfwbn  于 2023-01-13  发布在  Android
关注(0)|答案(1)|浏览(219)

我正在尝试使用cordova cli using命令构建混合应用程序

cordova build android

但它失败并显示错误(完整日志):

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

FAILURE: Build failed with an exception.

* Where:
Script '/home/iam/Projects/lave/platforms/android/CordovaLib/cordova.gradle' line: 75

* What went wrong:
A problem occurred evaluating script.
> No usable Android build tools found. Highest 30.x installed version is 27.0.1; Recommended version is 30.0.3.

* 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

我一直遵循这个step认为它会解决这个问题,但问题仍然存在,我得到同样的错误,即使在安装包。
来自我的Android SDK设置的实际图像:

值得一提的是,我已经使用apt安装了Android-SDK,之后我用这个命令设置了环境路径:

export ANDROID_HOME="/usr/lib/android-sdk/"
export PATH="${PATH}:${ANDROID_HOME}tools/:${ANDROID_HOME}platform-tools/"

在Android-SDK中安装软件包后,我重新启动Ubuntu,以为它会解决这个问题。但在尝试构建时仍然收到相同的错误消息。我错过了什么吗?

qncylg1j

qncylg1j1#

从错误日志中我认为它找不到您的ANDROID_SDK_ROOT,请检查它是否在您的环境变量中设置为这样:

export ANDROID_SDK_ROOT=/Users/[USERNAME]/Library/Android/sdk
export PATH=$ANDROID_SDK_ROOT/tools:$PATH

我相信你也应该像这样设置你的构建和平台工具的路径(当然是针对你的版本/路径):

export PATH=${PATH}:/Users/[USERNAME]/Library/Android/sdk/build-tools/33.0.0uild-tools/30.0.3
export PATH=${PATH}:/Users/[USERNAME]/Library/Android/sdk/platform-tools

你能检查一下你已经设置了所有这些,或者类似的东西吗?还要注意你可能需要在你的构建工具中修复一些东西(这是几个版本的情况,我不知道我的头顶是哪个,所以值得检查一下):Android Studio error "Installed Build Tools revision 31.0.0 is corrupted"

相关问题