I have a JNI library that works well on most Android devices - ARMv5, ARMv7, and x86.
I use NEON instructions on ARMv7, but instead of cluttering the code with a conditional / duplicate source, I want to detect non-NEON ARMv7 in Java while the library is loading and instead load the v5 library: a slow processor is slow.
I found a message suggesting that I look for the "neon" function in / proc / cpuinfo, so I parse this and load libthing.so usually or libthing-v5.so if the device claims to be ARMv7 without NEON. This works well on ARM.
Unfortunately, not only x86 emulates ARM / proc / cpuinfo (!), If it decides that it does not understand NEON, then it also digs out libthing-v5.so from the armeabiv7a directory and uses it because there isn t in the x86 directory .
My current solution is to simply copy the x86 library to libthing.so and libthing-v5.so, so if x86 pretends to be an ARMv7 chip, NEON-free, it will still get the x86 library.
Besides preparing a tiny, standalone library for architecture discovery based on our own Yeppp or Android processors, is there a way to define a true local Java architecture?
@ ph0b: At the same time, I show Razr that the emulator decided that the application is installed as "ABI2 58" and that it needs to fake / proc / cpuinfo.
Given that both shared libraries are available from x86, as well as in armeabi * directories, I donโt understand why the device decided to become ARM. I could ask my contact from Intel about this.
06-05 10:58:41.360 17807 18053 D dalvikvm: Trying to load lib /data/data/com.company.android/lib/libmp.so 0x42409cb0 06-05 10:58:41.360 17807 18053 D dalvikvm: Added shared lib /data/data/com.company.android/lib/libmp.so 0x42409cb0 06-05 10:58:41.370 17807 18053 D dalvikvm: No JNI_OnLoad found in /data/data/com.company.android/lib/libmp.so 0x42409cb0, skipping init 06-05 10:58:41.420 17807 18053 D : Searching package installed with ABI2 with Uid: 10109 06-05 10:58:41.420 17807 18053 D : Apps with ABI2 58 accessing /proc/cpuinfo 06-05 10:58:41.430 17807 18053 I System.out:
x86 arm android-ndk
android.weasel
source share