Could not determine java version from '9.0.1&#

2019-01-14 14:37发布

Trying upload project to bintray and just get error:

Could not determine java version from '9.0.1'.

I read that it's grade bug and it fixed in upper versions, I tried change gradle version to 4.2.1, but get another error:

Gradle sync failed: No such property: FOR_RUNTIME for class: org.gradle.api.attributes.Usage Consult IDE log for more details (Help | Show Log) (571ms)

Gradle properties:

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.2.1-all.zip

Build gradle project

buildscript {
    ext.kotlin_version = '1.1.51'

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0-beta7'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.novoda:bintray-release:0.5.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

6条回答
Summer. ? 凉城
2楼-- · 2019-01-14 15:14

This issue was in gradle version lower than 4.3, so update your gradle.properties to 4.3 or above:

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

Why this error occur?: Because of you have different JDK on your system than your android-studio JDK version.

Therefore your JDK should be compatible with each other, and by following this way you can manage that:

File -> Other settings -> Default project structure

enter image description here

You can use embedded JDK or use your own.


Also you may have some issues with terminal, and that's belong to a conflict between your multiple JDK.

Solution worked with me is to uninstall the java 9 JDK.

查看更多
神经病院院长
3楼-- · 2019-01-14 15:20

just tried to build with Gradle 4.3, against JDK 9.0.1 - this might possibly function in Android Studio (because the bundled JDK is an elder version), but not when building with Jenkins 2.89.2 (which seems to not support the JDK 9.0.1 yet, literally complaining Could not determine java version from '9.0.1'). bintray might also build with Jenkins, because the error message is somewhat identical.

downgrading to JDK 8 in gradle.properties fixed the issue for me:

org.gradle.java.home=/usr/java/jdk1.8.0_152

combined with gradle-wrapper.properties:

distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
查看更多
我想做一个坏孩纸
4楼-- · 2019-01-14 15:23

You should also delete Java JDK. Just run the following:

  1. cd /Library/Java/JavaVirtualMachines
  2. sudo rm -rf jdk1

Now check typing 'java' in your terminal.

For more references you can look here: https://www.howtogeek.com/230145/how-to-uninstall-java-on-mac-os-x/

查看更多
啃猪蹄的小仙女
5楼-- · 2019-01-14 15:23

In my case the error was

Could not determine java version from '10'.

I went to preferences in Unity (edit > preferences in windows or Unity > preferences in MAC), external tools, JDK dir and changed went up a couple of levels. I was using JDK 10, but changed to the folder of JDK 8 and this solved the issue.

查看更多
男人必须洒脱
6楼-- · 2019-01-14 15:30

Just need to use local gradle distribution Eg : In IntelliJ go to File->settings->Build,Execution,Deployment->Build Tools->Gradle then update the "Use local gradle distribution" as shown in image.

settings window

查看更多
乱世女痞
7楼-- · 2019-01-14 15:36

I had this problem on macOS and I solved it by:

Removing the too new java jdk

brew cask uninstall java

And installing an older one

brew tap caskroom/versions
brew cask install java8

All this handled via Homebrew

查看更多
登录 后发表回答