简体   繁体   English

哪个版本的Android SDK支持在哪个Java版本中进行编码?

[英]Which versions of Android SDK support coding in which versions of Java?

I was writing an Android app for Android SDK 2.3.3 but then I was asked to test it on a device running Android 2.2.1. 我正在为Android SDK 2.3.3编写一个Android应用程序,但随后我被要求在运行Android 2.2.1的设备上对其进行测试。 So I set my target to 8 instead of 10. But then java.util.concurrent.TimeUnit only had the Java 1.5 feature set instead of the Java 1.6/1.7 feature set of java.util.concurrent.TimeUnit. 因此,我将目标设置为8而不是10。但是java.util.concurrent.TimeUnit仅具有Java 1.5功能集,而不是java.util.concurrent.TimeUnit的Java 1.6 / 1.7功能集。 So I put the openjdk 6 implementation of TimeUnit into my package for my Android app and everything works fine. 因此,我将TimeUnit的openjdk 6实现放入我的Android应用程序包中,一切正常。

Does anyone know where I can get some documentation that gives me a chart that tells me, for example, that when using the official SDK, Android 2.2 has to be coded using Java 1.5 keywords/syntax/APIs, Android 2.3.3 can be coded using Java 1.6 keywords/syntax/APIs, etc...? 有谁知道我可以从哪里获得一些文档,该文档给我一个图表,告诉我,例如,使用官方SDK时,必须使用Java 1.5关键字/语法/ API来编码Android 2.2,可以对Android 2.3.3进行编码使用Java 1.6关键字/语法/ API等...?

You are trying to look at Android as a subset of Java which it is not. 您试图将Android视为不是Java的子集。 They are completely separated. 它们是完全分开的。 Even though Android comes from Java, it as departed from it quite a bit and there is no correlation 'version-wise' anymore between the two. 即使Android来自Java,它也与Java背道而驰,并且两者之间不再存在“版本方面”的关联。

What you can look at is the Android documentation. 您可以查看的是Android文档。 For every instruction/command/method/properties, at the top right you'll find the api level at which you are able to access said property. 对于每条指令/命令/方法/属性,在右上角都会找到您可以访问该属性的api级别。

Clicking on the api level will take you to a page which contains a table that translates api level to Android versions. 单击api级别将带您进入一个页面,该页面包含一个将api级别转换为Android版本的表。

The easy way to find out if you are allowed to use a property is using eclipse and doing what you just did : Change the target api level. 确定是否允许使用属性的简单方法是使用eclipse并执行您刚刚做的事情:更改目标api级别。 Then any call to methods or properties that are not available to you will produce fatal errors. 然后,任何对您不可用的方法或属性的调用都会产生致命错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM