2

I have many assumptions about android because I lack of knowledge of android internal. I'm developing apps with Android Studio. I usually search code snippet for java instead of android.

For example I search "java read file into byte array" rather than "android read file into byte array" so search results show java code snippets. But sometimes, I see something like - "JAVA 7+" or "java 6+" which I translate as - "this code only work if I'm writing for this version (or above) of java".

I'm running android studio with JRE version 8 so I'm sure that my code will work in android studio and my APK will be generated successfully. But I'm also afraid that if a device does not have that version of java, my APK will crash on that device. This is all because I have the following assumptions:

  1. android is based on JAVA and XML.
  2. so android has JRE or JDK internally.
  3. that JRE or JDK version(6/7/8..) depends on what android version that device has. For example may be Jellybean has JRE 6 and Oreo has JRE 8 etc (if it's true then what version has what?).
  4. my app will crash if I compile code for JAVA 8 and my APK meets a device that runs on a lower version of JRE.

That are my assumptions, it's a long question so I couldn't search it using keywords. Please guide me (tell me which assumption is wrong and what is right).

Benjamin
  • 7,055
  • 6
  • 40
  • 60
MbPCM
  • 457
  • 5
  • 12

2 Answers2

0

Android is an Operating System and not a programming language. It provides its own framework. The Android SDK has tools and API's built for developing android applications and it uses the Java programming language to do this. Hence why a large portion of Java libraries is supported in Android.

HoldTight
  • 205
  • 1
  • 2
  • 10
0

so after a while i found out what happens there after apk is created. acutally, every new java feature can be made compitable backward with help of some more libraries(meaning with some custum classes). for example, when you write lambda expression in androidStudio, it is Java8 feature. when your apk is compiled, it is converted to .class files. these .class files has an extra .class file which translates that lambda expressions in simple java bytecodes. then this .class file's bytecode converted into dex bytecodes. so basically java version affects only in Android Studio. it doesnt affect on your device because additional classes to support that feature are added to the apk when compiling.

MbPCM
  • 457
  • 5
  • 12