Search code examples
javaandroidjararmandroid-x86

What would be the point with different jars in android?


I know the difference of the native library between x86 and armeabi-v7a.

However, I found an app containing different jar library in x86 and armeabi-v7a folder. As I know, Java programs are cross-platform or platform independent. So what would be the point with different jars ?


Solution

  • The library probably uses Renderscript or interfaces with the Android NDK in some manner. Once you leave the Java world behind and delve into C/C++ world suddenly your code can become platform dependent when using pre-compiled code.

    When using the NDK you have to compile separate version of your code for different architectures when you build and Android will choose the correct one based on the system's architecture. So each jar file will most likely contain pre-compiled code, like CommonsWare mentioned.

    edit

    Some examples of pre-compiled code:

    • Database library - This person wrote a database library in C++ because it's quicker than using Java.
    • Digital Image Processing - Specialised code that can perform actions on bitmaps, performs faster in C than Java.

    All these pre-compiled pieces of code are compiled for different architectures into binary files so that they can be run without having to be interpreted first. They are generally accessed from C/C++ code which has not been pre-compiled but lives somewhere within the app that includes the pre-compiled code. It allows key functionality to live in isolation in these binary files.