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

Could not determine java version from '9.0.4'. #17688

Closed
thidasapankaja opened this issue Jan 21, 2018 · 25 comments
Closed

Could not determine java version from '9.0.4'. #17688

thidasapankaja opened this issue Jan 21, 2018 · 25 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@thidasapankaja
Copy link

Is this a bug report?

Yes

Have you read the Contributing Guidelines?

Yes

Environment

Environment:
OS: Linux 4.13
Node: 9.4.0
Yarn: Not Found
npm: 4.6.1
Watchman: Not Found
Xcode: N/A
Android Studio: 3.0 AI-171.4443003

Packages: (wanted => installed)
react: 16.2.0 => 16.2.0
react-native: 0.52.0 => 0.52.0

Steps to Reproduce

  1. Plugged an Android phone, enabled developer mode and debugging and confirmed that adb is recognised the device by running adb devices
  2. Followed the official docs and created a react-native app called AwesomeProject using react-native init AwesomeProject command.
  3. Changed the directory to inside the project and ran react-native run-android

Expected Behavior

Start the AwesomeProject in connected Android Device.

Actual Behavior

Didn't start the app on my mobile. Error on console appeared.

Scanning folders for symlinks in /home/pankaja/Documents/Projects/react-native/AwesomeProject/node_modules (7ms)
Starting JS server...
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 '9.0.4'.

* 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/android-setup.html
^C
pankaja@pankaja-HP-Pavilion-15-Notebook-PC:~/Documents/Projects/react-native/AwesomeProject$ react-native info

Screenshot

Reproducible Demo

react-native init AwesomeProject
cd AwesomeProject
react-native run-android
@irwanayeah
Copy link

I have same problem

Environment:
OS: Windows 10
Node: 7.10.1
Yarn: Not Found
npm: 4.2.0
Watchman: Not Found
Xcode: N/A
Android Studio: Not Found

Packages: (wanted => installed)
react: 16.2.0 => 16.2.0
react-native: 0.52.0 => 0.52.0

@TClark000
Copy link

Try #16536 to edit the gradle-wrapper.properties

@thidasapankaja
Copy link
Author

@TClark000 Thanks, I followed it and it worked.

Then another error occurred and fixed it by searching through Stackoverflow answers.

Now this error occurs.

Scanning folders for symlinks in /home/pankaja/Documents/Projects/react-native/AwesomeProject/node_modules (6ms)
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:
A problem occurred configuring project ':app'.
> Failed to notify project evaluation listener.
   > javax/xml/bind/annotation/XmlSchema

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 0s
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/android-setup.html

Couldn't find a way to fix this.

@katerynajeeva
Copy link

just in case you need a quick fix, you can uninstall JDK 9 and install JDK 8 instead

@fragaLY
Copy link

fragaLY commented Jan 23, 2018

@pankaja92
Could you please check you environment variables such as JAVA_HOME. (cmd: java -version)
Also it would be nice to update gradle to 4.4+ version.

@thidasapankaja
Copy link
Author

As @kate-kholyavkina suggested I removed and installed JDK 8. But now I'm getting another error.
@fragaLY I just removed and installed JDK 8 and now when I run java -version this is what I get.

java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)

And now when I run react-native run-android in my project folder, I'm getting this error.


File /home/pankaja/.android/repositories.cfg could not be loaded.
Checking the license for package Android SDK Build-Tools 23.0.1 in /home/pankaja/Android/Sdk/licenses
Warning: License for package Android SDK Build-Tools 23.0.1 not accepted.
Checking the license for package Android SDK Platform 23 in /home/pankaja/Android/Sdk/licenses
Warning: License for package Android SDK Platform 23 not accepted.


FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> You have not accepted the license agreements of the following SDK components:
  [Android SDK Platform 23, Android SDK Build-Tools 23.0.1].
  Before building your project, you need to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager.
  Alternatively, to learn how to transfer the license agreements from one workstation to another, go to http://d.android.com/r/studio-ui/export-licenses.html

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 54s
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/android-setup.html

@thidasapankaja
Copy link
Author

Fixed the main error by installing JDK 8 instead

@ykelanemer
Copy link

As @kate-kholyavkina suggested uninstall JDK 9 and install JDK 8 instead solved my issue.

@samaitra
Copy link

samaitra commented Feb 2, 2018

Hi

Following this guides helped me build the app in jdk9

https://github.com/gradle-guides/building-java-9-modules

HTH
Regards
Saikat

@azmanahmed21
Copy link

Hey, I had the same issue. I went to the gradle. properties file and changed the version in the 'distributionUrl' field to the latest version.

distributionUrl=https://services.gradle.org/distributions/gradle-4.4-all.zip

@neara
Copy link

neara commented Feb 13, 2018

I had same issue, on Mac.
First thing I did was change distributionUrl to latest gradle, that created other issues, but following gradle upgrade guid, i solved them and landed on having xmlSchema issue described here.
I didn't want to take the risk of uninstalling jdk 9 and I found following SO question which describes how to manage multiple java version on Mac:

https://stackoverflow.com/questions/26252591/mac-os-x-and-multiple-java-versions

Using jenv, i set local java to java8 and everything worked as it should.

@smakosh
Copy link

smakosh commented Feb 24, 2018

@kate-kholyavkina's solution worked fine!

@dhcmega
Copy link

dhcmega commented Mar 11, 2018

HI
I have uninstalled with:

sudo rm -fr /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
sudo rm -fr /Library/PreferencesPanes/JavaControlPanel.prefPane
sudo rm -fr ~/Library/Application\ Support/Java

and installed JDK8 but still getting the same error. How come?
Thanks!

Done, add also: sudo rm -fr /Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/

@dchersey
Copy link
Contributor

Running with Java 8 works for me too -- additionally don't forget to set JAVA_HOME in your .bashrc to the value returned by /usr/libexec/java_home -v

@TheGreatAndrew
Copy link

I ask 4 other React Native dev. They all said they have downgraded their Java version to 8.
For purpose of using react-native run-android.
-Use Java 8.
-Set ANDROID_HOME according to https://facebook.github.io/react-native/docs/getting-started.html
-Set JAVA_HOME according to http://www.sajeconsultants.com/how-to-set-java_home-on-mac-os-x/

@karna41317
Copy link

downgrade to java8 and set JAVA_HOME in .bash_* works

@LordST95
Copy link

just for some up the quick way (removing jdk9), run these commands:

sudo apt-get purge openjdk-9-jre-headless
sudo apt-get purge openjdk-9-jdk

@Blacktoviche
Copy link

If any one came across this problem. you don't have to downgrade java version
Just import the android folder into Android studio it will ask you to update gradle click update and when it finish everything is working fine
It worked for many for so many projects

@kevinzhangftw
Copy link

not sure what u mean by 'import the android folder into Android studio'

@Blacktoviche
Copy link

@kevinzhangftw Open Android Studio and click on ( Import project ) and select android folder in your react-native app

By using this way I built my react-native project using Java 10 too

@cassiehilton
Copy link

Thank you Blacktoviche! Great advice and it worked!

@hyochan
Copy link
Contributor

hyochan commented Jul 16, 2018

@Blacktoviche But then, we need to upgrade all projects first to actually begin editing the codes...

@djcurtin
Copy link

djcurtin commented Aug 2, 2018

Not to begin editing code; just to be able to run it on an emulator. It's an inconvenience, but not a huge one. And I doubt this is seen as the solution moving forward; likely a solution right now, and will be resolved in updates.

@asatalkar-ttm
Copy link

This is resolved by switching to lower Java SDK. As soon as I switch to 1.8 from 1.9 in Intellij and point my redirect my "PATH=%JAVA_HOME%\bin" in terminal, everything starts working!

@hmsmurtaza
Copy link

switching from java 9 to 8 resolved my issue

@facebook facebook locked as resolved and limited conversation to collaborators Jan 25, 2019
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jan 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