--To view this discussion on the web visit https://groups.google.com/d/msg/android-ndk/-/VU2hklB1LrgJ.
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.
On Mon, Feb 20, 2012 at 6:48 PM, David Turner <di...@android.com> wrote:
> I looked deeper into this issue and I confirm that the bug exists in all ICS
> releases to date, it's a platform bug, unrelated to the NDK itself :-(.
>
> The fix has been already submitted internally and should be part of the next
> minor platform update (sorry, can't give any ETAs here).
>
> I'm really sorry, this is really very unfortunate. At this point, there are
> two ways to work-around the issue:
It's pretty unfortunate indeed, but I found that automatic ABI
selection was already unreliable in the past on specific device (eg:
Milestone). This is of course different from a platform bug, but it
led me to decide not to rely on it, a long time ago.
> 1/ As mentioned previously, ensure that the armeabi-v7a binaries are
> packaged _after_ the armeabi ones in the final .apk. This is not trivial,
> but one way to do it is remove the armeabi-v7a files from the package, then
> add them back, manually.
>
> 2/ I believe a second way is to provide separate packages on market for
> different devices on Market, but it is also very painful.
I have a different approach. I put both arm and armv7 binaries into
the armeabi directory, and I then use the cpu-features library in
order to decide whether I load the optimized library or not, using
dlopen(). It works just great.
To avoid wasting space, this only concerns critical routines in my
code, but I suppose that a more global approach, eg implementing
JNI_OnLoad() as a wrapper, and registering native methods from the
dlopen()'ed object should be pretty easy.
--
Olivier
> On Feb 21, 9:56 am, Olivier Guilyardi<olivier.guilya...@gmail.com>
> wrote:
>> I have a different approach. I put both arm and armv7 binaries into
>> the armeabi directory, and I then use the cpu-features library in
>> order to decide whether I load the optimized library or not, using
>> dlopen(). It works just great.
>>
>> To avoid wasting space, this only concerns critical routines in my
>> code, but I suppose that a more global approach, eg implementing
>> JNI_OnLoad() as a wrapper, and registering native methods from the
>> dlopen()'ed object should be pretty easy.
>>
>> --
>> Olivier
>
> You're right that we can work around the platform choice of installed
> libraries. Unfortunately, even regardless the ICS bug, this platform
> choice has limited value because it lacks the wisdom to understand to
> choose between neon and Tegra.
For what's it's worth, the cpufeatures library included with the NDK can
detect neon supp�rt.
> As for the global approach, you can simply use LoadLibrary() from your
> Java code based on the CPU features. If you use a cpu-neutral JNI
> library that should choose between v7 or neon specific libraries, you
> should load these optimized libraries before you load the JNI library.
> This way, you can avoid dlopen() altogether.
Ah yeah right, LoadLibrary() is even better. You'd then just need a
minimal library that wraps cpufeatures, used to decide which object to
load from Java.
--
Olivier