You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Cordova无法找到Android Build Tools的问题求助

Cordova提示找不到已安装的Android Build Tools 33.0.2(树莓派Ubuntu环境)

问题场景

在树莓派的Ubuntu系统上使用Cordova开发Android应用,IntelliJ生成的Android SDK目录(/home/arco/Android/Sdk)中已安装33.0.2版本的Build Tools,且相关路径已加入$PATH,但执行cordova emulate android时仍报错:

No installed build tools found. Please install the Android build tools version 33.0.2.

尝试过移动Build Tools位置、升级/降级Gradle、重装Build Tools、升级Cordova等操作,问题仍未解决。完整报错输出如下:

Checking Java JDK and Android SDK versions
ANDROID_HOME=/home/arco/Android/Sdk (recommended setting)
ANDROID_SDK_ROOT=/home/arco/Android/Sdk (DEPRECATED)
Using Android SDK: /home/arco/Android/Sdk
Subproject Path: CordovaLib
Subproject Path: app
openjdk version "11.0.22" 2024-01-16
OpenJDK Runtime Environment (build 11.0.22+7-post-Ubuntu-0ubuntu223.10.1)
OpenJDK 64-Bit Server VM (build 11.0.22+7-post-Ubuntu-0ubuntu223.10.1, mixed mode)

FAILURE: Build failed with an exception.

* Where:
Script '/home/arco/Documents/Android/hello/platforms/android/CordovaLib/cordova.gradle' line: 69

* What went wrong:
A problem occurred evaluating script.
> No installed build tools found. Please install the Android build tools version 33.0.2.

* 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.6/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 1s
Command failed with exit code 1: /home/arco/Documents/Android/hello/platforms/android/gradlew -b /home/arco/Documents/Android/hello/platforms/android/build.gradle cdvBuildDebug

解决步骤

  • 检查Build Tools目录结构与权限

    1. 确认/home/arco/Android/Sdk/build-tools/下存在33.0.2文件夹,且包含完整工具文件(如aapt、dx、zipalign等)
    2. 赋予目录读写执行权限:
      sudo chmod -R 755 /home/arco/Android/Sdk/build-tools/33.0.2/
      
  • 验证环境变量配置

    1. 将以下配置写入~/.bashrc或~/.zshrc(根据使用的shell选择),确保环境变量持久化:
      export ANDROID_HOME=/home/arco/Android/Sdk
      export ANDROID_SDK_ROOT=/home/arco/Android/Sdk
      export PATH=$PATH:$ANDROID_HOME/platform-tools:$ANDROID_HOME/build-tools/33.0.2
      
    2. 执行source ~/.bashrc(或对应shell配置文件)使配置生效,然后验证:
      echo $ANDROID_HOME
      echo $PATH | grep build-tools
      
  • 强制指定Build Tools版本到项目配置

    1. 进入Cordova项目的platforms/android目录,编辑build.gradle,在android块中明确指定版本:
      android {
          buildToolsVersion "33.0.2"
          // 其他原有配置...
      }
      
    2. 检查CordovaLib/cordova.gradle文件(报错行所在文件),确认版本检测逻辑,若存在硬编码错误可手动修正为33.0.2。
  • 清理缓存并重建Android平台

    1. 清理项目缓存:
      cordova clean android
      
    2. 移除并重新添加适配的Android平台(Build Tools 33.0.2对应Android平台版本为12.0.0):
      cordova platform remove android
      cordova platform add android@12.0.0
      
  • 确认ARM架构兼容性
    树莓派为ARM架构,需确保下载的Build Tools适配ARM。使用命令行重新下载对应版本:

    sdkmanager "build-tools;33.0.2" --channel=3
    

内容的提问来源于stack exchange,提问作者Pazzel

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.28 10:12:50