location of installed .so files

3,995 views
Skip to first unread message

Alex Cohn

unread,
Jun 15, 2010, 12:37:41 PM6/15/10
to android-ndk
We all know that the APK installation puts libraries from project's
lib/armeabi foder into /data/data/<package>/lib folder. Usually, we
don't really care: System.loadLibrary() in static {} takes care of
this for us.

But in this specific case, I want to dlopen() a shared library from
another application's lib folder - this is a way I want to work around
an open-source licensing issue. If somebody installs the other
application in an alternative way, maybe on sdcard, will the shared
library still be found in /data/data/<package>/lib ? Or in another
well-defined folder? Or maybe, I can use PackageManager class to find
this location?

Sincerely,
Alex

Dianne Hackborn

unread,
Jun 15, 2010, 1:00:17 PM6/15/10
to andro...@googlegroups.com
Currently it will be in /data/data/<package>/lib, but I expect that to change in the future.


--
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.




--
Dianne Hackborn
Android framework engineer
hac...@android.com

Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails.  All such questions should be posted on public forums, where I and others can see and answer them.

Onur Cinar

unread,
Jun 15, 2010, 1:13:23 PM6/15/10
to android-ndk

Hi Alex,

Instead of making an assumption for the physical location of the
library, it would be better to locate it by searching the Java's
library path which can be obtained through
System.getProperty("java.library.path"), even through JNI.

However, in your case, since you would like to access some other
application's library, you may need to parse the path value and adjust
it based on the other application.

Regards,

-onur
---
www.zdo.com

Olivier Guilyardi

unread,
Jun 15, 2010, 1:40:07 PM6/15/10
to andro...@googlegroups.com
Hi Dianne,

how to determine this folder programmatically?

Is it with System.getProperty("java.library.path"), which Omar mentions? I can't
remember exactly why, but last time I tried, this didn't fit the job.

Is there any reliable way to know where the libs go?

Olivier

On 06/15/2010 07:00 PM, Dianne Hackborn wrote:
> Currently it will be in /data/data/<package>/lib, but I expect that to
> change in the future.
>
> On Tue, Jun 15, 2010 at 9:37 AM, Alex Cohn <sasha...@gmail.com
> <mailto:sasha...@gmail.com>> wrote:
>
> We all know that the APK installation puts libraries from project's
> lib/armeabi foder into /data/data/<package>/lib folder. Usually, we
> don't really care: System.loadLibrary() in static {} takes care of
> this for us.
>
> But in this specific case, I want to dlopen() a shared library from
> another application's lib folder - this is a way I want to work around
> an open-source licensing issue. If somebody installs the other
> application in an alternative way, maybe on sdcard, will the shared
> library still be found in /data/data/<package>/lib ? Or in another
> well-defined folder? Or maybe, I can use PackageManager class to find
> this location?
>
> Sincerely,
> Alex
>
> --
> 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

> <mailto:andro...@googlegroups.com>.


> To unsubscribe from this group, send email to
> android-ndk...@googlegroups.com

> <mailto:android-ndk%2Bunsu...@googlegroups.com>.


> For more options, visit this group at
> http://groups.google.com/group/android-ndk?hl=en.
>
>
>
>
> --
> Dianne Hackborn
> Android framework engineer

> hac...@android.com <mailto:hac...@android.com>


>
> Note: please don't send private questions to me, as I don't have time to
> provide private support, and so won't reply to such e-mails. All such
> questions should be posted on public forums, where I and others can see
> and answer them.
>

Eugene Mymrin

unread,
Jun 15, 2010, 2:14:08 PM6/15/10
to andro...@googlegroups.com
In your activity:

getPackageManager().getApplicationInfo(getPackageName(), 0).dataDir + "/lib/"

Olivier Guilyardi

unread,
Jun 15, 2010, 2:30:20 PM6/15/10
to andro...@googlegroups.com
This is what I'm currently doing.

But it's apparently not reliable, since Dianne is saying: "Currently it will be


in /data/data/<package>/lib, but I expect that to change in the future."

Is there any solution that I can expect to continue working if this changes?

You know, apps are released for at least 25 years :-p

Olivier

Olivier Guilyardi

unread,
Jun 16, 2010, 6:42:09 AM6/16/10
to andro...@googlegroups.com
If this folder can change to anything, then is the only reliable way: to bundle
libs as raw resources, and copy them to the internal memory before dlopen'ing?

Olivier

Alex Cohn

unread,
Jun 16, 2010, 6:59:51 AM6/16/10
to android-ndk
Eugene thanks, this should be the best strategy. I have also looked at
the sharedLibraryFiles field, but its does not reveal much info...
Does anybody know if this list of files is ever not null?

Alex

On Jun 15, 9:14 pm, Eugene Mymrin <emym...@gmail.com> wrote:
> In your activity:
>
> getPackageManager().getApplicationInfo(getPackageName(), 0).dataDir + "/lib/"
>
>
>
> On Tue, Jun 15, 2010 at 9:40 PM, Olivier Guilyardi <l...@samalyse.com> wrote:
> > Hi Dianne,
>
> > how to determine this folder programmatically?
>
> > Is it with System.getProperty("java.library.path"), which Omar mentions? I can't
> > remember exactly why, but last time I tried, this didn't fit the job.
>
> > Is there any reliable way to know where the libs go?
>
> > Olivier
>
> > On 06/15/2010 07:00 PM, Dianne Hackborn wrote:
> >> Currently it will be in /data/data/<package>/lib, but I expect that to
> >> change in the future.
>
> >> hack...@android.com <mailto:hack...@android.com>

Olivier Guilyardi

unread,
Jun 16, 2010, 7:05:22 AM6/16/10
to andro...@googlegroups.com
Alex, I don't know about sharedLibraryFiles, but what Eugene says isn't the best
strategy IMO: it's the same as using a private API of some kind, it might break
in the future, and according to this thread, it's even expected to break.

Olivier

Alex Cohn

unread,
Jun 16, 2010, 10:39:34 AM6/16/10
to android-ndk
Olivier, there is no way I can bundle 3rd party library as raw
resource. If it were possible, I could have just as easily put it in
my lib/armeabi folder.

What Eugene suggests, is replace hardcoded /data/data/<package> part
with "official" getPackageManager().getApplicationInfo(<package>,
0).dataDir, and only assume that the /lib part remains unchanged in
the future.

As for System.getProperty("java.library.path"), this does not help
because I am not looking for a library that is on "my" path anyway.

Alex

Olivier Guilyardi

unread,
Jun 16, 2010, 12:06:54 PM6/16/10
to andro...@googlegroups.com
I don't really get your point. Are you saying that you just can't bundle this
3rd party library into you apk?

Are you maybe loading the lib from the sdcard or downloading it?

In this case, the default <datadir>/lib folder won't be of any help to you, it's
read-only. You can't add anything in there.

Olivier

Olivier Guilyardi

unread,
Jun 16, 2010, 12:17:54 PM6/16/10
to andro...@googlegroups.com
Oups, sorry, I misread your original post: "But in this specific case, I want to
dlopen() a shared library from another application's lib folder".

Olivier

Reply all
Reply to author
Forward
0 new messages