The JDK used when writing Android, the JDK used when compiling Android applications, and some questions about the JDK version when Android applications are running?

  android, question

One problem I have not understood all along: what I am using now isJAVA 8TheJDKBut I am writingAndroidCode cannot be usedJAVA 8New features of (e.g.lambdaExpression). Why is this?
I heardAndroidOnly support tojava 6In other words, the application will not be compiled using what I specifiedJDKVersion, but compiled intoJDK 6The code of. Is that so? If so, thenAndroid StudioThere must be someJAVAProgram, then why specifyJDKPath?
There are written program callsJAVA APIIs it the same version on every mobile phone, do I use itjava7The method, but running on the machinejreThe environment isjava6, and then cannot find the method exception?
In general, it is in the process of writingAndroidWhen applied, yesJDKThere is some confusion in the version of the problem, please find the solution.

First of all, the early Android version is Java 6, and Java 7 can be used after Android version 4.4. In addition, earlier versions can be compiled with Java 7 as long as you don’t use it.try resourceThis new feature will suffice.

Then answer your question again, why can’t Android be compiled through Java 8? This is not to say that Android cannot be compiled by Java 8, but because the Android system running on every human machine is based on Java 6 or Java 7.DalvikEven if you compile Android programs with new features through Java 8, it cannot run on these machines. In addition, Android is not compiled purely in Java, and class files need to be converted into dex files after compilation, which is closely connected with the Android SDK. therefore, the Android SDK does not support Java 8 and cannot be upgraded by modifying JDK.