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

如何将ANDROID_HOME指向/usr/local/android-sdk?React Native编译报错求助

Fixing "Failed to find Build Tools revision 25.0" & Understanding ANDROID_HOME in React Native

Hey there, let's work through your React Native Android issues one by one:

1. Resolving the Missing Build Tools 25.0 Error

Even though your build.gradle specifies buildToolsVersion '26.0.1', the error about missing 25.0 likely comes from a dependency in your project that requires this specific build tool version. Here's how to install it:

  • Open Android Studio, go to Tools > SDK Manager
  • Switch to the SDK Tools tab
  • Check the box that says Show Package Details (top-right corner)
  • Scroll down to Android SDK Build-Tools, expand the list
  • Find and check the 25.0 version, then click Apply to install it

Once installed, try rebuilding your project again.

2. What Does "Point ANDROID_HOME to /usr/local/android-sdk" Mean?

ANDROID_HOME is an environment variable that tells tools like React Native, Gradle, and the Android build system where your Android SDK is installed on your computer. Setting it ensures these tools don't have to guess the SDK path, which avoids path-related errors.

How to Set It Up (Mac/Linux):

  1. Open your terminal and edit your shell configuration file (use ~/.bashrc for Bash, ~/.zshrc for Zsh, depending on your shell)
  2. Add these two lines to the file:
    export ANDROID_HOME=/usr/local/android-sdk
    export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
    
  3. Save the file, then run this command to apply the changes immediately:
    source ~/.zshrc  # Or source ~/.bashrc if you use Bash
    
  4. Verify it worked by running:
    echo $ANDROID_HOME
    
    You should see /usr/local/android-sdk printed in the terminal.

3. Quick Check of Your build.gradle Configuration

Looking at your config:

android {
    compileSdkVersion 26
    buildToolsVersion '26.0.1'
    defaultConfig {
        applicationId "xxxxxxxxxxxxx"
        minSdkVersion 19
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        ndk {
            abiFilters 'armeabi-v7a', 'x86'
        }
        manifestPlaceholders = [ ..... ]
    }
    ...
}
  • Your compileSdkVersion is 26, but targetSdkVersion is 25. For better compatibility, consider updating targetSdkVersion to 26 (unless you have specific dependencies that require 25). This can help avoid version mismatch warnings.
  • The rest of the config looks solid (multiDex enabled, correct ABI filters) — no red flags there.

After completing these steps, restart Android Studio and try running your React Native Android project again.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.15 08:17:16