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 from '11.0.1 #22487

Closed
Abdohurbly opened this Issue Dec 3, 2018 · 11 comments

Comments

Projects
None yet
8 participants
@Abdohurbly
Copy link

Abdohurbly commented Dec 3, 2018

Can't run app on Android Device :
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.0.1'.

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

@Abdohurbly Abdohurbly changed the title Could not determine java from '10.0.1 Could not determine java from '11.0.1 Dec 3, 2018

@peat-psuwit

This comment has been minimized.

Copy link
Contributor

peat-psuwit commented Dec 3, 2018

TL; DR Downgrade your Java version to Java 8

Sometime between Java 9 and Java 11, the format of java -version has changed, resulting in breakage in Gradle. Gradle has fixed the issue in Gradle 4.7, but React-native's template hasn't upgraded its Gradle version yet.

However, as upgrading Gradle may cause unwanted effects, I think you should workaround this by downgrading your Java version to Java 8. Meanwhile, maintainers can take a look if Gradle (& Android's build-tools) can be upgraded and if any steps are required first.

@react-native-bot

This comment has been minimized.

Copy link
Collaborator

react-native-bot commented Dec 3, 2018

Can you run react-native info and edit your issue to include these results under the Environment section?

If you believe this information is irrelevant to the reported issue, you may write [skip envinfo] under Environment to let us know.

@Abdohurbly

This comment has been minimized.

Copy link
Author

Abdohurbly commented Dec 3, 2018

OK I've downgrade the java version to 8: @peat-psuwit
getting this Error (even thought that I have local.properties in my root dir.
Error log:
FAILURE: Build failed with an exception.

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

SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.

  • 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 1s
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

@peat-psuwit

This comment has been minimized.

Copy link
Contributor

peat-psuwit commented Dec 3, 2018

If you followed the instruction in React-native's site, I recommend you to remove local.properties. Then it should use the value from the environment variable.

However, if you still can't build your app after that, I would recommend you to ask the question elsewhere and keep this issue about Java 11 support. https://hackr.io/forum/react-native seems to be a good place to start.

@Abdohurbly

This comment has been minimized.

Copy link
Author

Abdohurbly commented Dec 4, 2018

Thank you Mr. @peat-psuwit .
Solved
1- Delete Java 11 , 2-install Java 8 , 3-Create new file (local.properties) and set the SDK path in it .

@Abdohurbly Abdohurbly closed this Dec 4, 2018

@danwdart

This comment has been minimized.

Copy link

danwdart commented Jan 7, 2019

Was this updated in React Native now so one can use 11?

@SeanningTatum

This comment has been minimized.

Copy link

SeanningTatum commented Jan 8, 2019

@Abdohurbly in which directory did you create the local.properties and what did you write to set the SDK path?

@Bautista-Baiocchi-lora

This comment has been minimized.

Copy link

Bautista-Baiocchi-lora commented Jan 13, 2019

Is there anyway to run android without uninstalling java 11? I have tried changing gradle versions to: 5.0 but no luck.

@danwdart

This comment has been minimized.

Copy link

danwdart commented Jan 13, 2019

Yes - just use the ol' update-alternatives trick to select which version you want to use, or update the local environment variable $JAVA_HOME to the correct place.

E.g.:

# update-alternatives --list java
/usr/lib/jvm/java-11-openjdk-amd64/bin/java
/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
# update-alternatives --set java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
# java -version
openjdk version "1.8.0_191"
OpenJDK Runtime Environment (build 1.8.0_191-8u191-b12-0ubuntu0.18.10.1-b12)
OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)
# update-alternatives --set java /usr/lib/jvm/java-11-openjdk-amd64/bin/java
# java -version
openjdk version "11.0.1" 2018-10-16
OpenJDK Runtime Environment (build 11.0.1+13-Ubuntu-3ubuntu118.10ppa1)
OpenJDK 64-Bit Server VM (build 11.0.1+13-Ubuntu-3ubuntu118.10ppa1, mixed mode, sharing)
@ThaJay

This comment has been minimized.

Copy link

ThaJay commented Feb 28, 2019

You can use new Java with this:

buildscript.dependencies {
    classpath 'com.android.tools.build:gradle:3.2.1'
}

in global build.gradle

also change the gradle url to:

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

in gradle/wrapper/gradle-wrapper.properties

run the build once with old java and these changes, all subsequent builds succeed with new java.

@peat-psuwit it's fine. everything works like it should.

@vino4all

This comment has been minimized.

Copy link

vino4all commented Mar 2, 2019

# update-alternatives --list java
/usr/lib/jvm/java-11-openjdk-amd64/bin/java
/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
# update-alternatives --set java /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
# java -version
openjdk version "1.8.0_191"
OpenJDK Runtime Environment (build 1.8.0_191-8u191-b12-0ubuntu0.18.10.1-b12)
OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)

This helped me. Please note that # means superuser access so you may have to use sudo otherwise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.