cli: react-native doctor does not find ANDROID_HOME, ANDRIOD SDK and JDK
Environment
System: OS: Windows 10 10.0.17763 CPU: (12) x64 Intel® Core™ i7-9750H CPU @ 2.60GHz Memory: 5.40 GB / 15.86 GB Binaries: Node: 12.18.0 - C:\Program Files\nodejs\node.EXE Yarn: Not Found npm: 6.14.5 - C:\Program Files\nodejs\npm.CMD Watchman: Not Found SDKs: Android SDK: Not Found IDEs: Android Studio: Version 3.6.0.0 AI-192.7142.36.36.6392135 Languages: Java: Not Found Python: 3.8.3 npmPackages: @react-native-community/cli: Not Found react: 16.13.1 => 16.13.1 react-native: 0.63.0 => 0.63.0 npmGlobalPackages: react-native: Not Found
Description
Cannot find Android SDK, JDK, or Android_HOME even though its all available, shown below:
not sure if bug or other problem. This causes me to unable to do react-native run-android. Always shows the message below when I try to run it:
info Running jetifier to migrate libraries to AndroidX. You can disable it using “–no-jetifier” flag.
Jetifier found 970 file(s) to forward-jetify. Using 12 workers…
info JS server already running.
‘adb’ is not recognized as an internal or external command,
operable program or batch file.
info Launching emulator…
error Failed to launch emulator. Reason: No emulators found as an output of emulator -list-avds
.
warn Please launch an emulator manually or connect a device. Otherwise app may fail to launch.
info Installing the app…
ERROR: JAVA_HOME is not set and no ‘java’ command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the location of your Java installation.
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Run CLI with --verbose flag for more details. Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! Breakout@0.0.1 android: react-native run-android
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the Breakout@0.0.1 android script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\micha\AppData\Roaming\npm-cache_logs\2020-07-16T00_00_37_647Z-debug.log
Reproducible Demo
Don’t know how to reproduce it.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 5
- Comments: 58
This worked for me on windows 10:
Install android command line tools from android studio SDK manager (SDK tools tab). then add
<YOUR_ANDROID_SDK_PATH>\cmdline-tools\latest\bin
to PATH environment variablesAlso work for MacOS. For me, I just download
Android SDK Command-line Tools
: Android Studio -> Preferences -> search for sdk -> Click SDK Tools -> Tick onAndroid SDK Command-line Tools
-> Click OK to download. Then, thedoctor
should be able to find Android SDK.@its-kos I think I may have a solution for you, the same thing was troubling me and this approach fixed it. Little disclaimer, I’m using a mac…
Instead of installing the “latest” SDK Command-line Tools, install a specific version -
10.0
worked for me. You can achieve this by checking the “Show Package Details” at the bottom right of the window. After that, you need to supplement your$PATH
so it contains:<YOUR_ANDROID_SDK_PATH>\cmdline-tools\10.0\bin
- note the exact version instead of thelatest
.Hope this helps.
I have the same issue on Mac OS X 10.15.6 – I have loaded Android Studio which reports SDK is installed – and yet the doctor (version 4.12.0) cannot find it. (output follows)
I find it annoying that it’s idea of fixing things is to send me to a link that takes me to a page that has zero mention of the Android SDK – at the least it could tell me where it’s looking so that I could link the installed Android SDK into where it wants it…
I have set the ANDROID_HOME to the string that was in the Android Studio SDK settings pane, as well as to it’s parent directory. No Luck.
Please, where is the doctor looking for an sdk on the Mac??
This is what I did to fix it. I’m using react-native 0.72.4.
cmdline-tools
to your $PATHclass file version
reported by the error.Android SDK: Not Found still persists in 2023 despite all the recommendations aforementioned
This apparently does not work for me on Win 11.
I have everything and everything is on path. I dont know what else.
I still can’t understand how should i add the line, someone can tell me?
(export Users/user_name/Library/Android/sdk/cmdline-tools/latest/bin) - is it right?
worked for me, this is mac complete
vim ~/.zshrc
react-native doctor
After trying all of the solutions here, this was the only one that worked for my mac (with intel chip). Seems to be some issue with cmdline-tools v11
thanks too much! it realy help me . I try to install the java version 17 and then try to run npx react-native doctor, it works , and I spend 4hours to run yarn android , thanks gold , it finally run
I managed to solve it. Make sure you have the JAVA_HOME set up in both “User” and “System” variables. After adding both it managed to pick it up.
i try all the solutions of above, but the issue still persists, the error is:
npx react-native info:
Hello Everyone, I am a Windows User.
I made all the steps above and beyond, just by accident, I ran the
npm start
without having all the steps of thereact-native doctor
and everything worked perfectly.I just configured the
ANDROID_HOME
and added thesdk/platforms
in the path like the react-native documentation: https://reactnative.dev/docs/environment-setup and forget about what thereact-native doctor
said.Hope this help someone.
@osefatul
./gradlew
commands are working fine, no errorsAnd now the SDK is not recognized again WTF
Went back to
cmdline-tools/latest
, still N/AThis fixed it for me.