Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Android support JDK 6 or 7 [duplicate]

I am new to Android development. Can I use my existing Java code developed using JDK 7 in Android?

The functions use xerces dom and xslt and xpathapi. Currently when I installed Android Eclipse ADT environment these functions are not compiling. I would also like to know whether an Android device itself supports JRE 6 or 7?

like image 808
user3084351 Avatar asked Dec 09 '13 20:12

user3084351


People also ask

Does Android use Java 7?

Current tools can support all Java 7 and a few Java 8 features on all versions of Android.

What version of JDK does Android use?

A copy of the latest OpenJDK comes bundled with Android Studio 2.2 and higher, and this is the JDK version we recommend you use for your Android projects.

What version of Java does Android 11 use?

Java 8 APIs are available starting with Android 8 (API level 26). Some Java 9 APIs (like List. of()) are available starting with Android 11 (API level 30). These APIs might also be available on older Android versions through Java APIs desugaring.

Can I use Java 11 for Android?

Compilation with JDK11 is no longer supported in Android Studio 3.5 Beta 3.


1 Answers

Originally Android development tools supported only jdk 6 features. But that was changed, first by Android Studio 0.3.2 in October 2013 see: 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: enter image description here 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:

then by ADT plugin 22.6 in March 2014,see: http://developer.android.com/tools/sdk/eclipse-adt.html

Added support for Java 7 language features like multi-catch, try-with-resources, and the diamond operator. These features require version 19 or higher of the Build Tools. Try-with-resources requires minSdkVersion 19; the rest of the new language features require minSdkVersion 8 or higher. 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.

Android is not intended to be 100% compatible with any Java SE API version, not 6 nor 8 nor any. this was the reason of the court case of Oracle raised Against Google, accusing Google of fragmenting Java. Some APIs are impossible to implement on android as Swing; Imagine a window with a close button on android ! Others were delayed but implemented : for e.g.: Charset class is in Java SE 1.4 but implemented in android API 9, AutoClosable in Java 7 implemented in Android API level 19 to allow implementation of try-with-resources language feature. Some APIs are existent but for different purpose as Console.

like image 126
Muhammad Annaqeeb Avatar answered Sep 19 '22 20:09

Muhammad Annaqeeb