Android 是否支持 Java 11?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/53456107/
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
Does Android support Java 11?
提问by Seniru Pasan
I am new to android development. And I have installed eclipse, java 11 and android sdk tools in my computer. But when I try to build a project it says that to upgrade tools. But I have installed the latest sdk.
我是安卓开发的新手。我已经在我的电脑中安装了 eclipse、java 11 和 android sdk 工具。但是当我尝试构建一个项目时,它说要升级工具。但是我已经安装了最新的sdk。
When I'm reading in internet I found that android doesn't fully support java SE and it mostly support for java SE 6 and 7. - but this was an old post.
当我在互联网上阅读时,我发现 android 并不完全支持 java SE,它主要支持 java SE 6 和 7。 -但这是一篇旧帖子。
I found that android do not support java 11 completely.
我发现android不完全支持java 11。
My question is, what is the JDK version that fully support android and do I have to install 2 versions of JDK s in my computer?
我的问题是,什么是完全支持 android 的 JDK 版本,我是否必须在我的计算机中安装 2 个版本的 JDK?
回答by navylover
As official doc says:
正如官方文档所说:
Android Studio 3.0 and later supports all Java 7 language features and a subset of Java 8 language features that vary by platform version
Android Studio 3.0 及更高版本支持所有 Java 7 语言功能和 Java 8 语言功能的一个子集,这些功能因平台版本而异
so JDK 7is fully supported, and if you want to use some JDK 8 features, you should Make the appropriate settings.
所以JDK 7是完全支持的,如果你想使用JDK 8的一些特性,你应该进行适当的设置。
Here is the ref link for using Java 8
and android studio didn't support the java version higher than 8.
并且android studio不支持高于8的java版本。
回答by EJoshuaS - Reinstate Monica
You have the direction of fit backwards. Android supports certain versions of Java, not the other way around.
你有向后适合的方向。Android 支持某些版本的 Java,而不是相反。
That being said, Oracle Java and Android Java aren't really the same thing - they don't even use the same virtual machine, as a matter of fact. They're being developed completely separately.
话虽如此,Oracle Java 和 Android Java 并不是一回事——事实上,它们甚至不使用相同的虚拟机。它们是完全分开开发的。
As others have indicated, recent versions of Android supports up to Java 7 and a subset of Java 8 features. Older versions of Android may support less than that.
正如其他人所指出的,最新版本的 Android 最多支持 Java 7 和 Java 8 功能的一个子集。较旧版本的 Android 可能支持的更少。
回答by Mike
May be this 2 articles give more understanding on the situation:
可能是这2篇文章对这种情况有更多的了解:
Jake Wharton - Android's Java 9, 10, 11, and 12 Support
Jake Wharton - Android 的 Java 9、10、11 和 12 支持
Jake Wharton - Android's Java 8 Support
Jake Wharton - Android 的 Java 8 支持
Some features of java 9-12 also supported in Android if you set appropriate compileOptions, for example
例如,如果您设置了适当的 compileOptions,Android 也支持 java 9-12 的某些功能
compileOptions {
targetCompatibility JavaVersion.VERSION_12
sourceCompatibility JavaVersion.VERSION_12
}
P.S. for java 12 you need to set "likely latest" version of Gradle plugin.
PS for java 12 您需要设置 Gradle 插件的“可能最新”版本。