Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradle distribution needs to be updated in order to work with JDK v9 #16536

Closed
xzilja opened this issue Oct 25, 2017 · 17 comments
Closed

Gradle distribution needs to be updated in order to work with JDK v9 #16536

xzilja opened this issue Oct 25, 2017 · 17 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@xzilja
Copy link
Contributor

xzilja commented Oct 25, 2017

Is this a bug report?

Yes

Have you read the Contributing Guidelines?

Yes

Environment

Environment:
OS: macOS Sierra 10.12.6
Node: 8.7.0
Yarn: 1.2.1
npm: 5.5.1
Watchman: 4.9.0
Xcode: Xcode 9.0.1 Build version 9A1004
Android Studio: 2.3 AI-162.4069837

Packages: (wanted => installed)
react: 16.0.0-beta.5 => 16.0.0-beta.5
react-native: 0.49.3 => 0.49.3

Steps to Reproduce

  1. Update to JDK version 9+
  2. run react-native run-android

Expected Behavior

Should build android files correctly

Actual Behavior

Errors with following details

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine java version from '9.0.1'.

Solution seems to be described here: https://discuss.gradle.org/t/could-not-determine-java-version-from-9-0-1/24457 I tried it and got past the error, but had issues when opening project in my android studio, so am not sure if further steps are required.

@gregogalante
Copy link

gregogalante commented Nov 2, 2017

Get the same problem

@gregogalante
Copy link

This work for me:

Edit the file /android/gradle/wrapper/gradle-wrapper.properties and update the last line with:

distributionUrl=https\://services.gradle.org/distributions/gradle-4.3-rc-2-all.zip

So i update the gradle version used for project dependencies.

@xzilja
Copy link
Contributor Author

xzilja commented Nov 2, 2017

Opening project in android studio fixes this by prompting to update gradle version.

@lndgalante
Copy link

What it works for me was to rollback to Java8

brew cask uninstall java
brew tap caskroom/versions
brew cask install java8

@alexanderkjeldaas
Copy link

alexanderkjeldaas commented Jan 30, 2018

I don't think any of these workarounds are good.

  • Not using java9 is not a solution to not being able to use java9.
  • Using gradle 4.3 requires the android gradle plugin 3.0.0+ which requires flavors and other incompatible changes.
  • Updating the wrapper to latest version requires at least gradle 3.3.

In theory, updating to the latest gradle wrapper, and then upgrading gradle to only 3.3 and using the android plugin 2.3.0+ which might be compatible with RN might be a solution.

@ilezhnin
Copy link

Same with version '10'. "Could not determine java version from '10'.
"

@ditsayakul
Copy link

ditsayakul commented May 1, 2018

get the same problem

FAILURE: Build failed with an exception.

  • What went wrong:
    Could not determine java version from '10.0.1'.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
    Could not install the app on the device, read the error above for details.
    Make sure you have an Android emulator running or a device connected and have
    set up your Android development environment:
    https://facebook.github.io/react-native/docs/getting-started.html


I follow lndgalante roll back to java8. That is!! it work for me

brew cask uninstall java
brew tap caskroom/versions
brew cask install java8

@jorwan
Copy link

jorwan commented May 18, 2018

Same here...

captura de pantalla 2018-05-18 a la s 2 01 33 p m

@wangbax
Copy link

wangbax commented May 23, 2018

For me, I change my java version to java 8. It's work.
This is Link @jorwan @ditsayakul

@Beamanator
Copy link

I had the error Could not determine java version from '10.0.2'.

I followed @alexanderkjeldaas 's advice and upgraded Gradle. This also made me update the minimum sdk version, but now react-native run-android smoothly opens the app on the emulator.

I still see the warning WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'. It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html, but at least the app runs for now

@ajharry69
Copy link

ajharry69 commented Jul 26, 2018

@Beamanator which gradle version are you using or how did you update your gradle? Am having the exact same error as yours. Downgrading to Android Studio 2.3 is not part of my "todo" list!

@Beamanator
Copy link

@ajharry69 I'm using the following versions:
Android Studio: 3.1.3 (you didn't ask, but I'm just letting you know)
Emulator: Nexus 5, API level 26
Gradle distributionUrl: https://services.gradle.org/distributions/gradle-4.4-all.zip
-> Gradle Version: 4.4

@DixitaSO
Copy link

Gradle refresh failed
Error:Could not resolve all dependencies for configuration ':app:debugAndroidTestRuntimeClasspath'.
Could not determine artifacts for com.android.support.test:runner:1.0.1
Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/support/test/runner/1.0.1/runner-1.0.1.aar'.
Could not HEAD 'https://dl.google.com/dl/android/maven2/com/android/support/test/runner/1.0.1/runner-1.0.1.aar'.
dl.google.com

@dulmandakh
Copy link
Contributor

Closing this issue, because RN 0.56 uses gradle 4.x.

@benonymus
Copy link

Well I am having this issue right now with RN 0.56

Could not determine java version from '10.0.2'.

although as you say that it should be gradle 4.x when I am trying to run ./gradlew assemblerelease it showed that it downloaded gradle 3.5

@danielsellergren
Copy link

Same thing but for Java version 11.

$ react-native run-android
Scanning folders for symlinks in /Users/[redacted]/Code/[redacted]/node_modules (18ms)
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)...

 FAILURE: Build failed with an exception.

 * What went wrong:
 Could not determine java version from '11'.

Problem solved by changing the line in gradle-wrapper.properties to distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip which is the latest version as of right now. Still other problems but this solves this one.

@tmle
Copy link

tmle commented Sep 28, 2018

I follow danielsellergren's latest comment installing:
distributionUrl=https://services.gradle.org/distributions/gradle-4.10.2-all.zip

Got new error when running 'npm run android'

  • What went wrong:
    A problem occurred configuring project ':app'.

Failed to notify project evaluation listener.
javax/xml/bind/annotation/XmlSchema

@facebook facebook locked as resolved and limited conversation to collaborators Aug 25, 2019
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Aug 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests