React Native Doctor检测Android SDK版本异常的原因与解决咨询
Hey there, let's break down why this is happening and how to fix it quickly:
Why the Mismatch?
First, let's clarify: react-native doctor checks the Android SDK Build Tools versions you have installed locally on your machine, not just the values set in your project's build.gradle. Even though your project config specifies 28.0.3, it looks like the only Build Tools version actually installed on your system is 23.0.1, which doesn't meet the >=26.x requirement.
Step-by-Step Fix
Install the required Build Tools version via Android Studio
- Open Android Studio, go to
Tools > SDK Manager. - Switch to the
SDK Toolstab. - Check the box that says "Show Package Details" at the bottom right.
- Scroll down to
Android SDK Build Tools, expand the list, and check the box for28.0.3(or any version >=26.x that matches your project config). You can also uncheck23.0.1if you don't need it anymore to avoid confusion. - Click
Applyto start the installation.
- Open Android Studio, go to
Verify your ANDROID_HOME environment variable
Sometimes react-native doctor might be looking at the wrong SDK directory. Open your terminal and run:- On macOS/Linux:
echo $ANDROID_HOME - On Windows:
echo %ANDROID_HOME%
Make sure the path matches the SDK location you're using in Android Studio (you can find this in SDK Manager underAndroid SDK Locationat the top).
- On macOS/Linux:
Re-run react-native doctor
Once the installation is done, runnpx react-native doctoragain. It should now detect the correct Build Tools version and pass the check.
If you still run into issues, double-check that the Build Tools folder exists in your SDK directory (look for sdk/build-tools/28.0.3). Sometimes installations can fail silently, so retrying the install in Android Studio might help.
内容的提问来源于stack exchange,提问作者krissanawat

