-2

I use Android studio for my Android code base and my code uses ZipInputStream.java, which is provided by both Android SDK and JDK. It doesn't matter which version of SDK or JDK it is.

Strange thing is when I run my apk on Android-M and lower devices and emulators, the version of the above mentioned class comes from SDK but on Android N emulator, while using the same apk, ZipInputStream.java comes from the JDK.

How can I force Android N to use the classes from SDK by default and not JDK?

Please note that I have tried this by building the apk by using api 23 and 24 as both target and compile sdk versions, 23.x and 24.x versions for both build tools and support-v4. I even tried by using both JDK 7 and 8. It seems there's something with the Android N OS in how it chooses JDK classes over SDK classes that I might be missing. Help will be appreciated. Thanks in advance.

Dipali Shah
  • 3,742
  • 32
  • 47
FoY
  • 398
  • 1
  • 4
  • 17
  • 3
    *the version of the above mentioned class comes from SDK* no ... if you run app on device/emulator it use ZipInputStream implementation from runtime library of the device/emulator ... also how did you "check" it? – Selvin Aug 23 '16 at 09:45
  • I confirmed by placing breakpoints in both versions of the file. Also, for Android-N it behaves exactly like the JDK version of the files expects it to. For – FoY Aug 23 '16 at 09:55

1 Answers1

1

but on Android N emulator, while using the same apk, ZipInputStream.java comes from the JDK

The device/emulator always uses the ZipInputStream implementation that is on the device/emulator. There is no Java source code on the device/emulator.

Now, Android 7.0/N shifted a lot of java.* and javax.* classes from the original, Apache Harmony-based editions to ones that are based on the OpenJDK. I do not know whether ZipInputStream changed or not.

How can I force Android N to use the classes from SDK by default and not JDK?

You don't. The implementation of framework classes, including java.* and javax.* classes, comes from the device/emulator, not your app.

On the whole, the migration from Harmony to the OpenJDK has been fairly smooth. If you are running into compatibility issues, where ZipInputStream no longer behaves as it did, create a reproducible test case and file an issue.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Thanks. pretty elaborate answer. Wonder if people down-voting my question knew this. Had they known they'd have commented. Thanks again. – FoY Aug 23 '16 at 13:55