Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
194 views
in Technique[技术] by (71.8m points)

android - Could not determine java version from '9.0.1'

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
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...