How to fix the error "Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8." in React Native?
See original GitHub issueDescription
[admin@DF713 android % ./gradlew app:installDebug FAILURE: Build failed with an exception.
-
Where: Build file ‘/Users/admin/Downloads/ritehauler-user/android/app/build.gradle’ line: 1
-
What went wrong: A problem occurred evaluating project ‘:app’.
Failed to apply plugin ‘com.android.internal.application’. Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8. You can try some of the following options: - changing the IDE settings. - changing the JAVA_HOME environment variable. - changing
org.gradle.java.home
ingradle.properties
.
- 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
I am running the command from zsh terminal. Thanks.
Version
0.67.2
Output of npx react-native info
System: OS: macOS 11.6 CPU: (4) x64 Intel® Core™ i7-8700B CPU @ 3.20GHz Memory: 64.71 MB / 8.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 14.17.5 - ~/.nvm/versions/node/v14.17.5/bin/node Yarn: 1.22.17 - ~/Downloads/ritehauler-user/node_modules/.bin/yarn npm: 6.14.14 - ~/.nvm/versions/node/v14.17.5/bin/npm Watchman: 2022.01.24.00 - /usr/local/bin/watchman Managers: CocoaPods: 1.11.2 - /Users/admin/.gem/bin/pod SDKs: iOS SDK: Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4 Android SDK: API Levels: 28, 29, 32 Build Tools: 29.0.2, 32.1.0 System Images: android-29 | Intel x86 Atom_64, android-29 | Google APIs Intel x86 Atom, android-29 | Google Play Intel x86 Atom, android-30 | Google Play Intel x86 Atom_64 Android NDK: Not Found IDEs: Android Studio: 2021.1 AI-211.7628.21.2111.8092744 Xcode: 12.5/12E262 - /usr/bin/xcodebuild Languages: Java: 1.8.0_292 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 17.0.2 => 17.0.2 react-native: 0.67.2 => 0.67.2 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found
Steps to reproduce
Run react-native run-android in project root directory.
Snack, code example, screenshot, or link to a repository
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (1 by maintainers)
Top GitHub Comments
Thanks @cortinico
I updated jdk with flowing commands:
Thanks @mMarcos208
brew tap homebrew/cask-versions
brew install --cask zulu11
this command worked for me.