You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

如何通过终端解决Android SDK Build Tools版本过低问题

解决SDK Build Tools版本过低问题及内部修复流程解析

Hey there! Let's unpack this issue for you clearly, since you already have some basic grasp but want to understand the inner workings better.

First, let's clarify the root of that error message:

"The SDK Build Tools revision (23.0.1) is too low for project"

This error pops up because your project's Gradle plugin version and the specified SDK Build Tools version are incompatible. Newer Gradle plugins rely on updated Build Tools to support new Android features, bug fixes, and compatibility standards—so an old Build Tools version can't keep up.

What happens when you click Android Studio's fix prompt?

When you tap that auto-fix button in AS, here's the behind-the-scenes flow:

  • First, it checks the Gradle plugin version your project uses (look in the root build.gradle file's dependencies block, like classpath 'com.android.tools.build:gradle:x.x.x'), then maps it to the recommended compatible SDK Build Tools version.
  • Next, it automatically updates the buildToolsVersion field in each module's build.gradle file, replacing the old version (23.0.1 in your case) with the matched compatible one.
  • It also checks if this new Build Tools version is already installed in your local SDK. If not, it prompts you to open the SDK Manager to download and install it.
  • Finally, it triggers a Gradle sync to apply the new configuration across your project.

Alternative approach: Use the latest stable SDK Build Tools

If you prefer to manually use the highest available stable Build Tools version, follow these steps:

  1. Open the SDK Manager (via the SDK icon in AS's top-right corner), navigate to the SDK Build Tools section, and install the latest stable version (skip preview builds marked with rc or beta unless you're testing experimental features).
  2. Open each module's build.gradle file, find the android block, and update the buildToolsVersion to your newly installed version. For example:
    android {
        buildToolsVersion "34.0.0" // Replace with your installed latest stable version
        // Other configurations...
    }
    
  3. Click the "Sync Project with Gradle Files" button in the AS toolbar to finalize the changes.

A quick note: While using the latest Build Tools usually works smoothly, some older projects might run into compatibility issues with outdated libraries. If that happens, you'll need to roll back to a version that's compatible with both your Gradle plugin and project dependencies.

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

火山引擎 最新活动