我是 Android 开发新手。我可以在 Android 中使用使用 JDK 7 开发的现有 Java 代码吗?
这些函数使用 xerces dom、xslt 和 xpathapi。目前,当我安装Android Eclipse ADT环境时,这些函数未编译。我还想知道Android设备本身是否支持JRE 6或7?
最初Android开发工具仅支持jdk 6功能。但这种情况已经改变,首先是 2013 年 10 月的 Android Studio 0.3.2 看到:http://tools.android.com/recent/androidstudio032released
Support for language features like the diamond operator, multi-catch, try-with-resources, strings in switches, etc.
When creating a new project, you can specify a source language level:
Note that you can use all these language features not just with Android KitKat, but with older versions of Android too! There is one exception to that: try-with-resources, which will require minSdkVersion 19. Therefore, Studio will flag any uses in your code of try-with-resources if your minSdkVersion is less than 19:
然后通过2014年3月的ADT插件22.6,参见:http://developer.android.com/tools/sdk/eclipse-adt.html
添加了对 Java 7 语言功能(如多重捕获、try-with-resources 和菱形运算符)的支持。这些功能需要版本 19 或更高版本的构建工具。 Try-with-resources 需要 minSdkVersion 19;其余新语言功能需要 minSdkVersion 8 或更高版本。
要在安装 ADT 22.6.0 后使用新的语言功能,请确保在 JDK 7 上运行 Eclipse 并将应用程序项目设置更改为使用 JDK 7。
Android 并不打算与任何 Java SE API 版本 100% 兼容,无论是 6、8 还是任何版本。这就是甲骨文向谷歌提起诉讼的原因,指控谷歌分裂Java。有些API是不可能像Swing一样在android上实现的;想象一下 Android 上有一个带有关闭按钮的窗口!其他的则被延迟但已实现:例如:Charset 类在 Java SE 1.4 中,但在 Android API 9 中实现,Java 7 中的 AutoClosable 在 Android API 级别 19 中实现,以允许实现 try-with-resources 语言功能。有些 API 是存在的,但其用途与控制台不同。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)