简体   繁体   English

JDK 7和Android IDE

[英]JDK 7 and Android IDE

I have jdk 6 and 7 installed on my PC. 我的电脑上安装了jdk 6和7。

On this link https://developer.android.com/sdk/index.html#ExistingIDE , I read that Android IDE is compatible with jdk 6, but I want to know if Android SDK works also with jdk 7 or if there are problems ? 在这个链接https://developer.android.com/sdk/index.html#ExistingIDE上 ,我读到Android IDE与jdk 6兼容,但我想知道Android SDK是否也适用于jdk 7或者是否存在问题?

If there are problems can I mantain the jdk 7 and configure Android sdk to use Jdk 6 ? 如果有问题我可以保留jdk 7并配置Android sdk以使用Jdk 6吗?

You can build a project using JDK 7 in Eclipse with the ADT plugin with no extra configuration and with any version of the ADT plugin, so long as you only use features in JDK 6. 您可以使用JDT 7在Eclipse中使用ADT插件构建项目,无需额外配置和任何版本的ADT插件,只要您只使用JDK 6中的功能即可。

Support for Java 7 language features was added to the Eclipse ADT plugin in March 2014 (ADT 22.6.0 and up). Eclipse ADT插件于2014年3月(ADT 22.6.0及更高版本)添加了对Java 7语言功能的支持。 All you need to do is update your application project settings to use JDK 7 and ensure that Eclipse is running on JDK 7 as well. 您需要做的就是更新应用程序项目设置以使用JDK 7并确保Eclipse也在JDK 7上运行。

Note that unless your minSdkVersion is 19+ (KitKat), you cannot use try-with-resources. 请注意,除非你的minSdkVersion是19+(KitKat),否则你不能使用try-with-resources。

From the ADT plugin tools page : ADT插件工具页面

ADT 22.6.0 (March 2014) ADT 22。6。0(2014年3月)

General Notes: 一般注意事项:

  • Added support for Java 7 language features like multi-catch, try-with-resources, and the diamond operator. 添加了对Java 7语言功能的支持,如multi-catch,try-with-resources和diamond操作符。 These features require version 19 or higher of the Build Tools. 这些功能需要构建工具的19或更高版本。 Try-with-resources requires minSdkVersion 19; 尝试使用资源需要minSdkVersion 19; the rest of the new language features require minSdkVersion 8 or higher. 其余的新语言功能需要minSdkVersion 8或更高版本。

    To use the new language features after installing ADT 22.6.0, ensure that you run Eclipse on JDK 7 and change your application project settings to use JDK 7. 要在安装ADT 22.6.0之后使用新的语言功能,请确保在JDK 7上运行Eclipse并更改应用程序项目设置以使用JDK 7。

Yes, you can use Java 1.7 for the android development. 是的,你可以使用Java 1.7进行android开发。

Starting from build tools 19, Android has full support for Java 1.7. 从构建工具19开始,Android完全支持Java 1.7。 So you can set 1.7 as source and target for compilation. 因此,您可以将1.7设置为编译的源和目标。 Support for this is from Android studio 0.3.2. 对此的支持来自Android studio 0.3.2。 Android kitkat has full support of JAVA 1.7 API, but most of language features from 1.7, can be used on the older android versions too. Android kitkat完全支持JAVA 1.7 API,但1.7的大多数语言功能也可用于较旧的Android版本。

Edit: You can also mantain the jdk 7 and configure the Android application to use Jdk 6 during compilation. 编辑:您还可以保留jdk 7并配置Android应用程序以在编译期间使用Jdk 6。

It's not even necessary to have JDK 6 installed. 甚至不需要安装JDK 6。 You can just configure Eclipse to "compile as JDK 6" and it will work. 您可以将Eclipse配置为“编译为JDK 6”,它将起作用。

To change for the whole workspace, enter Window -> Preferences , then Java -> Compiler and set Compiler compliance level to 1.6. 要更改整个工作区,请输入Window - > Preferences ,然后输入Java - > Compiler并将Compiler compliance level设置为1.6。

You can also do this in individual projects, if you prefer, in Project -> Properties -> Java Compiler . 如果您愿意,也可以在项目 - > 属性 - > Java编译器中在单个项目中执行此操作。

I noticed the same problem today http://developer.android.com/sdk/installing/installing-adt.html where the recommended jdk is 1.6 but according to the main bundle Android has full support for 1.7 http://developer.android.com/sdk/installing/index.html?pkg=studio . 我今天注意到同样的问题http://developer.android.com/sdk/installing/installing-adt.html其中推荐的jdk是1.6但是根据主要的捆绑包Android完全支持1.7 http://developer.android .com / sdk / installing / index.html?pkg = studio

So I woudl say...Yes! 所以我想说......是的! 8 ) 8)

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

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