Andreas Falkenhahn
2018-04-25 14:51:56 UTC
I have a shared object bundled with my Android app. It is in the "lib" folder of the
APK. On Android 7 I can just do the following to load it:
lib = dlopen("libfoo.so", RTLD_LAZY);
However, this doesn't work on Android 4. On Android 4 I have to do the following instead:
lib = dlopen("/data/data/<my_package_identifier>/lib/libfoo.so", RTLD_LAZY);
But opening from /data/data/.../ doesn't work on Android 7. So the solution I've come
up with is something like this:
if(!(lib = dlopen("libfoo.so", RTLD_LAZY))) {
lib = dlopen("/data/data/<my_package_identifier>/lib/libfoo.so", RTLD_LAZY);
}
This will work on both, Android 4 and Android 7, but of course it feels hackish.
So what is the official way to do it please?
NB: I know that it is easier from the Java side using System.loadLibrary() but I
don't want to use that either because it doesn't allow me to unload libraries.
--
Best regards,
Andreas Falkenhahn mailto:***@falkenhahn.com
APK. On Android 7 I can just do the following to load it:
lib = dlopen("libfoo.so", RTLD_LAZY);
However, this doesn't work on Android 4. On Android 4 I have to do the following instead:
lib = dlopen("/data/data/<my_package_identifier>/lib/libfoo.so", RTLD_LAZY);
But opening from /data/data/.../ doesn't work on Android 7. So the solution I've come
up with is something like this:
if(!(lib = dlopen("libfoo.so", RTLD_LAZY))) {
lib = dlopen("/data/data/<my_package_identifier>/lib/libfoo.so", RTLD_LAZY);
}
This will work on both, Android 4 and Android 7, but of course it feels hackish.
So what is the official way to do it please?
NB: I know that it is easier from the Java side using System.loadLibrary() but I
don't want to use that either because it doesn't allow me to unload libraries.
--
Best regards,
Andreas Falkenhahn mailto:***@falkenhahn.com
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk+***@googlegroups.com.
To post to this group, send email to android-***@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/1931192621.20180425165156%40falkenhahn.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk+***@googlegroups.com.
To post to this group, send email to android-***@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/1931192621.20180425165156%40falkenhahn.com.
For more options, visit https://groups.google.com/d/optout.