Java in Android is a variant of Java

Android app development uses Java platform and you can consume JDK (java development toolkit) in Android.

This above statement is partially true however the fact is that some part of Java SDK is being pulled out and packaged it in Android SDK. Second fact is that we can use Java language to consume Android SDK. However today, it is recommended to use Java 6 for Android projects. (I will come to answer that why)

Notice If you expand the android.jar you can view that it is composed of several different packages of open source libraries. So Android SDK is actually a collection of snapshot of several open source libraries at a particular time such as Java SDK/OpenJDK, Apache HttpClient,, w3c dom etc. and of course the android core APIs and some of them are even uniquely modified for Android.

This all leads to an interesting question in the community I read some days ago on Reddit

Can we leverage Java 8 features in Android?

The answer is not yet.

Why? (you ask!)

Because remember we read that Android run on its own Dalvrik VM instead of Java standard VM (JVM) to convert byte code to executable.Therefore if any feature has been added in Java 8, its written to produce certain byte code by Java compiler which is then worked out by updated JVM. However that features needs to be supported in Dalvrik VM as well. Plus authors of Android needs to pull latest version of Java packages into the android.jar.

Hope this clears out confusion for some android developers!

Further readings:

  1. Java vs. Android APIs
  2. Will Android get Java 7 or 8 in a forseeable future?
  • Sheeraz Shaikh

    Thanks Adil, you have shared a useful information. I was wondering why java 8 code can not be used in Android and you just answered my query 🙂

  • Great info adil bai..mashallah