react-native-community / cli

The React Native Community CLI - command line tools to help you build RN apps
MIT License
2.38k stars 902 forks source link

react-native doctor does not find ANDROID_HOME, ANDRIOD SDK and JDK #1220

Closed michaelhzh closed 1 year ago

michaelhzh commented 4 years ago

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! 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.

ajoslin103 commented 4 years ago

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.
mtsunu commented 4 years ago

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

sungsong88 commented 4 years ago

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

abhi0504 commented 4 years ago

@mtsunu Nice work buddy , this works for me

mobihunterz commented 3 years ago

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.

tungduonghgg123 commented 3 years ago

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

Also work for MacOS. For me, I just download Android SDK Command-line Tools : Android Studio -> Preferences -> search for sdk -> Click SDK Tools -> Tick on Android SDK Command-line Tools-> Click OK to download. Then, the doctor should be able to find Android SDK. Screen Shot 2021-10-01 at 23 31 19

suyashvash commented 2 years ago

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

Totally worked , fixed the Android SDK error in react-native doctor

AnatuGreen commented 2 years ago

I had this same issue. Mine was even showing that:

    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: 29.0.3
 ✓ ANDROID_HOME

Errors:   2
Warnings: 0 
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.

enter image description here

I got fed up with all the steps that are online that are not working and just clicked on 'e'. It took its time and installed the said missing programs (note that I already installed Android studio and all the SDK instructions on react-native docs before now but for some reason it was not being detected)

When I ran npx react-native doctor, the issue was resolved:

enter image description here

Note that this may consume some amount of bandwidth since it is re-downloading Android studio and all other dependencies(maybe everything should be about 2GB of data), and a strong internet connection is recommended.

BATUCHKA commented 2 years ago

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?

BATUCHKA commented 2 years ago

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

how could you do it? can i take a look of your terminal screen shot or something?

web3walle commented 2 years ago

cmdline-tools\latest\bin

worked for me, this is mac complete

vim ~/.zshrc

export ANDROID_SDK_ROOT=$HOME/Library/Android/sdk
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_SDK_ROOT/emulator
export PATH=$PATH:$ANDROID_SDK_ROOT/platform-tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH=$PATH:$ANDROID_HOME/cmdline-tools\latest\bin

react-native doctor

cwsh commented 1 year ago

export PATH=$PATH:$ANDROID_HOME/cmdline-tools\latest\bin

Note that this should use forward slashes throughout: export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin

I can confirm that this worked for me.

Sidenote: If you are using zsh you may want to utilize it's mapping structures and write it like this: https://stackoverflow.com/a/18077919/16898137 Same result though.

jtovarto commented 1 year ago

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

It works for me too on Linux!

AlexNolasco commented 1 year ago

Android SDK: Not Found still persists in 2023 despite all the recommendations aforementioned


    OS: macOS 13.2
    CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
    Memory: 10.82 GB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 19.6.0 - /usr/local/bin/node
    Yarn: Not Found
    npm: 9.4.0 - /usr/local/bin/npm
    Watchman: 2023.02.13.00 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.11.3 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1
    Android SDK: Not Found
  IDEs:
    Android Studio: 2022.1 AI-221.6008.13.2211.9514443
    Xcode: 14.2/14C18 - /usr/bin/xcodebuild
  Languages:
    Java: 19.0.2 - /usr/local/opt/openjdk/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.1.0 => 18.1.0
    react-native: 0.70.6 => 0.70.6
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found```
github-actions[bot] commented 1 year ago

There hasn't been any activity on this issue in the past 3 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 7 days.

its-kos commented 1 year ago

This apparently does not work for me on Win 11. image image

I have everything and everything is on path. I dont know what else.

kof3r commented 1 year ago

@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 the latest.

Hope this helps.

image

JoyCood commented 1 year ago

i try all the solutions of above, but the issue still persists, the error is:

knight@192 awasome % npx react-native doctor
Common
 ✓ Node.js - Required to execute JavaScript code
 ✓ yarn - Required to install NPM dependencies
 ✓ Watchman - Used for watching changes in the filesystem when in development mode

Android
 ✓ Adb - Required to verify if the android device is attached correctly
 ✓ JDK - Required to compile Java code
 ✓ 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: 33.0.0
 ✓ ANDROID_HOME - Environment variable that points to your Android SDK installation

iOS
 ✓ Xcode - Required for building and installing your app on iOS
 ✓ Ruby - Required for installing iOS dependencies
 ✓ CocoaPods - Required for installing iOS dependencies
 ● ios-deploy - Required for installing your app on a physical device with the CLI
 ✓ .xcode.env - File to customize Xcode environment

Errors:   1
Warnings: 1

Attempting to fix 1 issue...

Android
 ✖ Android SDK
   Read more about how to download Android SDK at https://reactnative.dev/docs/environment-setup?os=macos&platform=android&guide=native#android-sdk

npx react-native info:

knight@192 awasome % npx react-native info
info Fetching system and libraries information...
System:
  OS: macOS 11.3
  CPU: (8) arm64 Apple M1
  Memory: 95.38 MB / 8.00 GB
  Shell:
    version: "5.8"
    path: /bin/zsh
Binaries:
  Node:
    version: 16.19.1
    path: ~/.nvm/versions/node/v16.19.1/bin/node
  Yarn:
    version: 1.22.19
    path: /opt/homebrew/bin/yarn
  npm:
    version: 8.19.3
    path: ~/.nvm/versions/node/v16.19.1/bin/npm
  Watchman:
    version: 2023.03.06.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.12.0
    path: /Users/knight/.rvm/gems/ruby-2.7.2/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 21.2
      - iOS 15.2
      - macOS 12.1
      - tvOS 15.2
      - watchOS 8.3
  Android SDK: Not Found
IDEs:
  Android Studio: 2022.3 AI-223.8836.35.2231.10406996
  Xcode:
    version: 13.2.1/13C100
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 11.0.15
    path: /usr/bin/javac
  Ruby:
    version: 2.7.2
    path: /Users/knight/.rvm/rubies/ruby-2.7.2/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.72.4
    wanted: 0.72.4
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false
its-kos commented 1 year ago

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.

dviluk commented 1 year ago

This is what I did to fix it. I'm using react-native 0.72.4.

  1. Add cmdline-tools to your $PATH
export PATH=$ANDROID_HOME/cmdline-tools/<latest>/bin:$PATH # replace <latest> with the version you have
  1. Check if there are errors with your SDK
$ sdkmanager --list
Error: LinkageError occurred while loading main class com.android.sdklib.tool.sdkmanager.SdkManagerCli
    java.lang.UnsupportedClassVersionError: com/android/sdklib/tool/sdkmanager/SdkManagerCli has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0
  1. In my case, I have to download the correct java version based on the class file version reported by the error.
class file version
Java 8 52.0
Java 9 53.0
Java 10 54.0
Java 11 55.0
Java 12 56.0
Java 13 57.0
Java 14 58.0
Java 15 59.0
Java 16 60.0
Java 17 61.0
Java 18 62.0
Java 19 63.0
Java 20 64.0
Java 21 65.0
Java 22 66.0
  1. Done
gcarramate commented 1 year ago

@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 the latest.

Hope this helps.

image

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

lxt-ing commented 1 year ago

This is what I did to fix it. I'm using react-native 0.72.4.

  1. Add cmdline-tools to your $PATH
export PATH=$ANDROID_HOME/cmdline-tools/<latest>/bin:$PATH # replace <latest> with the version you have
  1. Check if there are errors with your SDK
$ sdkmanager --list
Error: LinkageError occurred while loading main class com.android.sdklib.tool.sdkmanager.SdkManagerCli
  java.lang.UnsupportedClassVersionError: com/android/sdklib/tool/sdkmanager/SdkManagerCli has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0
  1. In my case, I have to download the correct java version based on the class file version reported by the error.

class file version Java 8 52.0 Java 9 53.0 Java 10 54.0 Java 11 55.0 Java 12 56.0 Java 13 57.0 Java 14 58.0 Java 15 59.0 Java 16 60.0 Java 17 61.0 Java 18 62.0 Java 19 63.0 Java 20 64.0 Java 21 65.0 Java 22 66.0

  1. Done

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

daonamutc1 commented 1 year ago

export PATH=$PATH:$ANDROID_HOME/cmdline-tools\latest\bin

In my case, if I follow your method and need to clean gradlew.

lxt-ing commented 1 year ago

export PATH=$PATH:$ANDROID_HOME/cmdline-tools\latest\bin

In my case, if I follow your method and need to clean gradlew.

I haven't run gradlew command , I just do something like below:

  1. install java 17version
  2. install command-line tools 10 version in Android Studio,In my Android Studio , command-line tools always show not installed though I installed it before
  3. go to ANDROID_HOME/cmdline-tools/ dir and rename the 10 filename as latest make sure you have config the path to the system environment I don't known if all of the step to make it works , but after do that , project run successfully
yanukadeneth99 commented 1 year ago
sdkmanager --list

Worked for me on Ventura 13.5 - Installing Java@17

VMBindraban commented 1 year ago

@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 the latest. Hope this helps. image

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

This fixed it for me.

XeeshanAnsari commented 1 year ago

I am still getting the same error on macOS Sonoma

Android SDK - Required for building and installing your app on Android

zane-commeatio commented 1 year ago

I am still getting the same error on macOS Sonoma

Android SDK - Required for building and installing your app on Android

  • Versions found: N/A
  • Version supported: 33.0.0

Same error here

Tried the infinite propositions found around the internet

Here is my .zshrc

export ANDROID_SDK_ROOT=$HOME/Library/Android/sdk
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/tools/bin:$PATH
export JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home
export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin
export PATH=$PATH:/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home/bin

Below some informations that might be usefull

image

image

image

image

./android/local.properties :

## This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Sun Oct 08 16:50:30 ICT 2023
sdk.dir=/Users/zane/Library/Android/sdk

./android/settings.gradle :

rootProject.name = 'XXX'
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'
includeBuild('../node_modules/@react-native/gradle-plugin')
apply from: new File(["node", "--print", "require.resolve('expo/package.json')"].execute(null, rootDir).text.trim(), "../scripts/autolinking.gradle")
useExpoModules()

Here the installed Android sdks : image image image

Outputs of react native commands : doctor : image

info : image

NOTE :

using ./gradlew assembleReleaseProd or ./gradlew installDevDebug is working but npx react-native run-android is not

yanukadeneth99 commented 1 year ago

I am still getting the same error on macOS Sonoma Android SDK - Required for building and installing your app on Android

  • Versions found: N/A
  • Version supported: 33.0.0

Same error here

Tried the infinite propositions found around the internet

Here is my .zshrc

export ANDROID_SDK_ROOT=$HOME/Library/Android/sdk
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/tools/bin:$PATH
export JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home
export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin
export PATH=$PATH:/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home/bin

Below some informations that might be usefull

image

image

image

image

./android/local.properties :

## This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Sun Oct 08 16:50:30 ICT 2023
sdk.dir=/Users/zane/Library/Android/sdk

./android/settings.gradle :

rootProject.name = 'XXX'
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'
includeBuild('../node_modules/@react-native/gradle-plugin')
apply from: new File(["node", "--print", "require.resolve('expo/package.json')"].execute(null, rootDir).text.trim(), "../scripts/autolinking.gradle")
useExpoModules()

Here the installed Android sdks : image image image

Outputs of react native commands : doctor : image

info : image

NOTE :

using ./gradlew assembleReleaseProd or ./gradlew installDevDebug is working but npx react-native run-android is not

Hey mate, check the message above. For me, Java@17 worked and not Java@11 - Specifically check this - https://github.com/react-native-community/cli/issues/1220#issuecomment-1707592654

yanukadeneth99 commented 1 year ago

I am still getting the same error on macOS Sonoma

Android SDK - Required for building and installing your app on Android

  • Versions found: N/A
  • Version supported: 33.0.0

Did this not work?

zane-commeatio commented 1 year ago
sdkmanager --list

I tried to install openjdk@17

This seems to have moved forward because now doctor has the green check image

But on info I still see openjdk@11 image

My env variables are now :

export JAVA_HOME=/Library/Java/JavaVirtualMachines/openjdk-17.jdk/Contents/Home
export PATH=$PATH:/Library/Java/JavaVirtualMachines/openjdk-17.jdk/Contents/Home/bin

But when I java --version image it seems like the @17 is not taken despite the JAVA_HOME pointing to it

also the sdkmanager --list is outputing this image But as the java version found is still the @11 it makes sens

yanukadeneth99 commented 1 year ago
sdkmanager --list

I tried to install openjdk@17

This seems to have moved forward because now doctor has the green check image

But on info I still see openjdk@11 image

My env variables are now :

export JAVA_HOME=/Library/Java/JavaVirtualMachines/openjdk-17.jdk/Contents/Home
export PATH=$PATH:/Library/Java/JavaVirtualMachines/openjdk-17.jdk/Contents/Home/bin

But when I java --version image it seems like the @17 is not taken despite the JAVA_HOME pointing to it

also the sdkmanager --list is outputing this image But as the java version found is still the @11 it makes sens

Looks like your system still picks up Java@11. Make sure to check out an uninstaller or use brew to uninstall + make sure to restart the terminal to pickup the new changes.

I get Java@17

image
zane-commeatio commented 1 year ago
sdkmanager --list

I tried to install openjdk@17 This seems to have moved forward because now doctor has the green check image But on info I still see openjdk@11 image My env variables are now :

export JAVA_HOME=/Library/Java/JavaVirtualMachines/openjdk-17.jdk/Contents/Home
export PATH=$PATH:/Library/Java/JavaVirtualMachines/openjdk-17.jdk/Contents/Home/bin

But when I java --version image it seems like the @17 is not taken despite the JAVA_HOME pointing to it also the sdkmanager --list is outputing this image But as the java version found is still the @11 it makes sens

Looks like your system still picks up Java@11. Make sure to check out an uninstaller or use brew to uninstall + make sure to restart the terminal to pickup the new changes.

I get Java@17

image

Allright I have java17 now showing up image

react-native doctor still all green

and react-native info showing java17 too image

./gradlew installDevDebug is still working

But still when I run-android : image

No error message, very frustrating

zane-commeatio commented 1 year ago

And I still can't use that sdkmanager command image

I have no idea what is error means

osefatul commented 1 year ago

I had the same issue, what worked for me:

zane-commeatio commented 1 year ago

I had the same issue, what worked for me:

  • In your android directory you must have a local.properties. Just add this line there: sdk.dir=/Users/<user>/Library/Android/sdk.
  • Go to the android folder and run ./gradlew clean.
  • Restart the server.

Thanks, but I tried this already and no success

image

VMBindraban commented 1 year ago

@zane-commeatio Do you have SDK tools 11 installed? I had to uninstall it for 10 to work.

zane-commeatio commented 1 year ago

@zane-commeatio Do you have SDK tools 11 installed? I had to uninstall it for 10 to work.

I have 11 but in latest form image

Will try to install 11 without the latest tag

VMBindraban commented 1 year ago

@zane-commeatio Do you have SDK tools 11 installed? I had to uninstall it for 10 to work.

I have 11 but in latest form image

Will try to install 11 without the latest tag

11 didn't work me at all, 10 worked fine.

zane-commeatio commented 1 year ago

@zane-commeatio Do you have SDK tools 11 installed? I had to uninstall it for 10 to work.

I have 11 but in latest form image Will try to install 11 without the latest tag

11 didn't work me at all, 10 worked fine.

Just tried with 11.0 and 10.0

image

updated $PATH export PATH=$PATH:$ANDROID_HOME/cmdline-tools/10.0/bin

image

No success

zane-commeatio commented 1 year ago

And now the SDK is not recognized again WTF

image

Went back to cmdline-tools/latest, still N/A

osefatul commented 1 year ago

@zane-commeatio I just solved my issue setting configurations such as below: image image image

Make sure you install same API 33 when creating a virtual device. Once you are done with that. Then go through this again. https://github.com/react-native-community/cli/issues/1220#issuecomment-1752611171

Also, install java17, and then go through this process: image image

I hope this resolves your issue!

zane-commeatio commented 1 year ago

@zane-commeatio I just solved my issue setting configurations such as below: image image image

Make sure you install same API 33 when creating a virtual device. Once you are done with that. Then go through this again. #1220 (comment)

Also, install java17, and then go through this process: image image

I hope this resolves your issue!

But the setup in the official docs is set to java11

Also, i'm on macos so I can't reproduce exactly this process

Anyway here is the new config :

image

image

image

export ANDROID_SDK_ROOT=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/cmdline-tools/10.0/bin

image

image

Result :

image

osefatul commented 1 year ago

@zane-commeatio I think your configurations are good. But, what was the error when you run this command'./gradlew clean' in the android directory? I believe you need to get some errors after running it and solving that will solve the sdk issue. When I set my configurations I run the command and it gave me JAVA_HOME error, when I resolved it, it automatically resolved the sdk error as well. btw, make sure you are closing and opening the command-line after each change as it holds previous results.

zane-commeatio commented 1 year ago

@osefatul ./gradlew commands are working fine, no errors

LewdinAc commented 1 year ago

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 the react-native doctor and everything worked perfectly.

image

I just configured the ANDROID_HOME and added the sdk/platforms in the path like the react-native documentation: https://reactnative.dev/docs/environment-setup and forget about what the react-native doctor said.

image

Hope this help someone.

szymonrybczak commented 1 year ago

Hey @LewdinAc, yeah we have an issue with detecting SDK version - could you please run doctor outside of project and provide result?

LewdinAc commented 1 year ago

Hey @LewdinAc, yeah we have an issue with detecting SDK version - could you please run doctor outside of project and provide result?

Of course, the result outside of project is the same: image

miguel-olivera-chr commented 1 year ago

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

If "latest" doesn't work, just try a specific version, for me it was 10, so the environment variable looks like: <YOUR_ANDROID_SDK_PATH>\cmdline-tools\10.0\bin

Hope this helps

dviluk commented 1 year ago

And I still can't use that sdkmanager command image

I have no idea what is error means

Can you try with another SDK? Like AdoptOpenJDK, etc