无法从“9.0.1”确定 java 版本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/46893768/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Could not determine java version from '9.0.1'
提问by no news
Trying upload project to bintray
and just get error:
尝试将项目上传到bintray
并得到错误:
Could not determine java version from '9.0.1'.
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
版本更改为4.2.1
,但出现另一个错误:
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 同步失败:没有这样的属性:类的 FOR_RUNTIME:org.gradle.api.attributes.Usage 有关更多详细信息,请咨询 IDE 日志(帮助 | 显示日志)(571 毫秒)
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
构建gradle项目
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
}
采纳答案by David
You should also delete Java JDK. Just run the following:
您还应该删除 Java JDK。只需运行以下命令:
- cd /Library/Java/JavaVirtualMachines
- sudo rm -rf jdk1
- cd /Library/Java/JavaVirtualMachines
- 须藤rm -rf jdk1
Now check typing 'java' in your terminal.
现在检查在终端中输入“java”。
For more references you can look here: https://www.howtogeek.com/230145/how-to-uninstall-java-on-mac-os-x/
有关更多参考,您可以在这里查看:https: //www.howtogeek.com/230145/how-to-uninstall-java-on-mac-os-x/
回答by no news
This issue was in gradle version lower than 4.3
, so update your gradle.properties to 4.3
or above:
此问题的 gradle 版本低于4.3
,因此将您的 gradle.properties 更新为4.3
或更高版本:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.3-all.zip
Why this error occur?: Because of you have different JDKon your system than your android-studio JDKversion.
为什么会出现这个错误?:因为您系统上的JDK与您的 android-studio JDK版本不同。
Therefore your JDKshould be compatible with each other, and by following this way you can manage that:
因此,您的JDK应该相互兼容,通过这种方式,您可以进行管理:
File
-> Other settings
-> Default project structure
File
-> Other settings
->Default project structure
You can use embedded JDKor use your own.
您可以使用嵌入式JDK或使用您自己的。
Also you may have some issues with terminal
, and that's belong to a conflict between your multiple JDK.
此外,您可能有一些问题terminal
,这属于您的多个JDK之间的冲突。
Solution worked with me is to uninstall the java 9 JDK.
与我一起工作的解决方案是卸载 java 9 JDK。
回答by E. Sundin
回答by Martin Zeitler
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.
只是尝试使用 Gradle 4.3 构建,针对 JDK 9.0.1 - 这可能在 Android Studio 中起作用(因为捆绑的 JDK 是旧版本),但在使用 Jenkins 2.89.2 构建时不起作用(似乎不支持 JDK 9.0 .1 然而,字面意思是抱怨Could not determine java version from '9.0.1'
)。bintray 也可能使用 Jenkins 构建,因为错误消息有些相同。
downgrading to JDK 8 in gradle.properties
fixed the issue for me:
降级到 JDK 8gradle.properties
为我解决了这个问题:
org.gradle.java.home=/usr/java/jdk1.8.0_152
combined with gradle-wrapper.properties
:
结合gradle-wrapper.properties
:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
回答by Alok Verma
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.
只需要使用本地 gradle 发行版 例如:在 IntelliJ 中,转到 File->settings->Build,Execution,Deployment->Build Tools->Gradle 然后更新“使用本地 gradle 发行版”,如图所示。
回答by Guilherme Carvalho
In my case the error was
在我的情况下,错误是
Could not determine java version from '10'.
无法从“10”确定 Java 版本。
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.
我转到了 Unity 中的首选项(编辑 > Windows 中的首选项或 Unity > MAC 中的首选项)、外部工具、JDK 目录并更改了几个级别。我使用的是 JDK 10,但更改为 JDK 8 的文件夹,这解决了问题。
回答by Parthiban
Make sure your files under JDK are accessible. I had same issue because my process was not able to access my JDK files due to proxy issue. Then i changed my JDK path. It worked.
确保 JDK 下的文件可访问。我遇到了同样的问题,因为由于代理问题,我的进程无法访问我的 JDK 文件。然后我改变了我的JDK路径。有效。