Cli: react-native doctor does not find ANDROID_HOME, ANDRIOD SDK and JDK

Created on 16 Jul 2020  ·  5Comments  ·  Source: react-native-community/cli

Environment

System:
OS: Windows 10 10.0.17763
CPU: (12) x64 Intel(R) Core(TM) 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:
Annotation 2020-07-15 201018
Annotation 2020-07-15 201002

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! [email protected] android: react-native run-android
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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.

bug report

Most helpful comment

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 variables

All 5 comments

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??

Common
 ✓ Node.js
 ✓ yarn
 ✓ Watchman - Used for watching changes in the filesystem when in development mode

Android
 ✓ JDK
 ✓ Android Studio - Required for building and installing your app on Android
 ✖ Android SDK - Required for building and installing your app on Android
   - Versions found: N/A
   - Version supported: 28.0.3
 ✓ ANDROID_HOME

iOS
 ✓ Xcode - Required for building and installing your app on iOS
 ✓ CocoaPods - Required for installing iOS dependencies
 ● ios-deploy - Required for installing your app on a physical device with the CLI

Errors:   1
Warnings: 1

Usage
 › Press f to try to fix issues.
 › Press e to try to fix errors.
 › Press w to try to fix warnings.
 › Press Enter to exit.

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 variables

Thank you @mtsunu!!! Hey OP. @mtsunu's got the answer here!! His way works in on Mac as well!!

@mtsunu Nice work buddy , this works for me

I have working project in Expo and just ejected the project using expo-eject.
My Android and iOS folders are prepared and I have followed enough steps to run iOS project which is working perfect. However, I am facing issues while running Android build.

First, I was getting error with npx @react-native-community/cli doctor regarding Android SDK. And so, I looked upon the above solution which really worked for me when I install command tools and appended cmdline-tools into $PATH.

However, still when I check react-native info, it shows me

Android SDK:
API Levels: 29, 30
Build Tools: 28.0.3, 29.0.2, 30.0.3
System Images: android-30 | Google APIs Intel x86 Atom

Android NDK: Not Found

And when I try with react-native run-android, my build fails with following error:

> Task :app:processDebugManifest FAILED

See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.


Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.3/userguide/command_line_interface.html#sec:command_line_warnings
501 actionable tasks: 2 executed, 499 up-to-date
/Users/pareshthakor/Workspace/Jeavio/CMA/CMAMobileApp/android/app/src/debug/AndroidManifest.xml Error:
    Attribute data@scheme at AndroidManifest.xml requires a placeholder substitution but no value for <appAuthRedirectScheme> is provided.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : Attribute data@scheme at AndroidManifest.xml requires a placeholder substitution but no value for <appAuthRedirectScheme> is provided.

* 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

BUILD FAILED in 11s

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 app:installDebug -PreactNativeDevServerPort=8081
/Users/pareshthakor/Workspace/Jeavio/CMA/CMAMobileApp/android/app/src/debug/AndroidManifest.xml Error:

It says some Manifest merger failed.

Please let me know if there is anything else I have to do here.

Regards.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lucasbento picture lucasbento  ·  3Comments

ferrannp picture ferrannp  ·  4Comments

mauricioscotton picture mauricioscotton  ·  3Comments

lucasbento picture lucasbento  ·  3Comments

thymikee picture thymikee  ·  4Comments