How to substitute dlopen in Android N?

780 views
Skip to first unread message

Andreas Falkenhahn

unread,
Jan 27, 2017, 3:58:30 PM1/27/17
to andro...@googlegroups.com
I have an NDK app which can be extended via plugins which are loaded via dlopen.
This used to work fine but it no longer works with Android N. As stated in the
7.0 release notes, dlopen support is now officially abandoned. (see here:
https://developer.android.com/about/versions/nougat/android-7.0-changes.html#ndk )

That's why I need to change my plugin design into something that is officially
supported and is future-proof. The most obvious choice would be to use
Android's Service API and simply distribute my plugins as separate APKs that
implement a Service.

However, I don't really like that idea since I'm using the NDK and I don't think
that the Service API is available for the NDK. Of course, I could create a Service
in Java and then use JNI to integrate it with my C code but this is of course not
a very elegant solution.

That's why I'd like to ask what's the recommended way to support plugins which were
previously dlopen-based in Android N? Is there an alternative route or am I forced
to use the Service API now?

--
Best regards,
Andreas Falkenhahn mailto:and...@falkenhahn.com

Philippe Simons

unread,
Jan 27, 2017, 4:33:21 PM1/27/17
to android-ndk
It's not stated that dlopen is abandoned / deprecated.
It's stated that using dlopen to access private API is now forbidden...

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to andro...@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/1091397811.20170127212633%40falkenhahn.com.
For more options, visit https://groups.google.com/d/optout.

Andreas Falkenhahn

unread,
Jan 27, 2017, 5:57:09 PM1/27/17
to Philippe Simons, andro...@googlegroups.com
On 27.01.2017 at 22:32 Philippe Simons wrote:

> It's not stated that dlopen is abandoned / deprecated.
> It's stated that using dlopen to access private API is now forbidden...

Well, yeah, that's what I meant of course. On Android N I'm no longer able to
dlopen() non-system shared objects. That's why I'm wondering how I should
solve this problem...

Dan Albert

unread,
Jan 27, 2017, 6:09:03 PM1/27/17
to android-ndk, Philippe Simons
On Android N I'm no longer able to
dlopen() non-system shared objects. That's why I'm wondering how I should
solve this problem...

As in you can't dlopen something within your app? 

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to andro...@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.

J Decker

unread,
Jan 27, 2017, 11:32:31 PM1/27/17
to andro...@googlegroups.com, Philippe Simons
On Fri, Jan 27, 2017 at 3:08 PM, 'Dan Albert' via android-ndk <andro...@googlegroups.com> wrote:
On Android N I'm no longer able to
dlopen() non-system shared objects. That's why I'm wondering how I should
solve this problem...

As in you can't dlopen something within your app? 
Should be just that you can't open in other's apps (like installing a common shared openCV library that others link to) and system libraries that aren't meant to be linked to.


On Fri, Jan 27, 2017 at 2:41 PM, Andreas Falkenhahn <and...@falkenhahn.com> wrote:
On 27.01.2017 at 22:32 Philippe Simons wrote:

> It's not stated that dlopen is abandoned / deprecated.
> It's stated that using dlopen to access private API is now forbidden...

Well, yeah, that's what I meant of course. On Android N I'm no longer able to
dlopen() non-system shared objects. That's why I'm wondering how I should
solve this problem...

--
Best regards,
 Andreas Falkenhahn                            mailto:and...@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+unsubscribe@googlegroups.com.
To post to this group, send email to andro...@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/936559614.20170127234140%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+unsubscribe@googlegroups.com.
To post to this group, send email to andro...@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.

J Decker

unread,
Jan 27, 2017, 11:33:46 PM1/27/17
to andro...@googlegroups.com
On Fri, Jan 27, 2017 at 8:32 PM, J Decker <d3c...@gmail.com> wrote:


On Fri, Jan 27, 2017 at 3:08 PM, 'Dan Albert' via android-ndk <andro...@googlegroups.com> wrote:
On Android N I'm no longer able to
dlopen() non-system shared objects. That's why I'm wondering how I should
solve this problem...

As in you can't dlopen something within your app? 
Should be just that you can't open in other's apps (like installing a common shared openCV library that others link to) and system libraries that aren't meant to be linked to.
And maybe in data space; which makes 'download a plugin to add functionality' kinda improbable. 

Andreas Falkenhahn

unread,
Jan 28, 2017, 11:51:52 AM1/28/17
to andro...@googlegroups.com
On 28.01.2017 at 00:08 'Dan Albert' via android-ndk wrote:

> As in you can't dlopen something within your app?

Oops, sorry, actually, dlopen() is still working fine on Android 7.0. I was getting
the following error message:

Detected problems with app native libraries (please consult log for detail):
foobar.so: text relocations

I thought that this was caused by the new dlopen() policy in Android N but
actually it was caused by a bug in Android NDK r8b which I was still using.
Updating to a newer NDK solved the problem.

Still, I'm wondering what exactly does Google mean when they say that starting
in Android 7.0 "the system prevents apps from dynamically linking against non-NDK
libraries"? To me this sounds like dlopen()'ing non-system libraries is forbidden
now but as I said, it still works so I guess I'm misunderstanding something here?
But what does Google mean by it then?

Dan Albert

unread,
Jan 28, 2017, 1:18:42 PM1/28/17
to android-ndk
I guess the wording does technically make it sound like you're now allowed to link to your own libraries. That definitely is not the case. The policy is that your cannot link to or dlopen private system libraries (anything in /system/lib that is not in the NDK).

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to andro...@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.

Grégory Pakosz

unread,
Jan 28, 2017, 1:23:18 PM1/28/17
to android-ndk
On Saturday, January 28, 2017 at 7:18:42 PM UTC+1, Dan Albert wrote:
I guess the wording does technically make it sound like you're now allowed to link to your own libraries. That definitely is not the case. The policy is that your cannot link to or dlopen private system libraries (anything in /system/lib that is not in the NDK).

In that respect, it's about time NDK gives us a way to get a backtrace ;) 

Dan Albert

unread,
Jan 28, 2017, 2:03:37 PM1/28/17
to android-ndk
In that respect, it's about time NDK gives us a way to get a backtrace ;) 

That's actually coming very soon! https://android-review.googlesource.com/c/325718/

It's landing in the platform for O, but I plan on shipping it as part of the NDK once we work out any of the kinks.

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to andro...@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
Reply all
Reply to author
Forward
0 new messages