1

My 32-bit ARM Android apps come with .so files that I dlopen() in my native code. This works just fine, and I can dlopen them at the /data/data/com.domain.app/lib/libX.so location.

If I add 64-bit binaries to my package (arm64-v8a) and install it on a 64 bit Android device, then there will be no /data/data/com.domain.app/lib directory present.

After some investigation, I found that the .so files on a 64-bit Android device end up in a different directory:

/data/app/com.domain.app-1/lib/arm64

And to make matters worse, the '-1' suffix varies, and could be '-2' or something else.

This is a way to check what got installed in the application's home directory:

$ adb shell run-as com.steenriver.biplane '/system/bin/sh -c "pwd"' /data/data/com.steenriver.biplane

$ adb shell run-as com.steenriver.biplane '/system/bin/sh -c "ls -al"' drwxrwx--x u0_a108 u0_a108 2017-01-17 15:04 app_.gpg.classloader drwxrwx--x u0_a108 u0_a108 2017-01-17 15:04 cache drwxrwx--x u0_a108 u0_a108 2017-01-17 15:04 code_cache drwxrwx--x u0_a108 u0_a108 2017-01-17 15:04 files

A 32 bit device will have a lib/ entry listed here.

Is there an Android call I can do (Either in Java or native code) that will tell me where the .so files have ended up, so I can dlopen() them?

1 Answer 1

4

For 64-bit ARM, there is no longer a symbolic link made to the library directory. To find the .so files, you can use the following Java code in onCreate()

import android.content.pm.PackageInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
...
ApplicationInfo ainfo = this.getApplicationContext().getPackageManager().getApplicationInfo
( 
    "com.domain.app",
    PackageManager.GET_SHARED_LIBRARY_FILES
);
Log.v( TAG, "native library dir " + ainfo.nativeLibraryDir );

Compare this with 32-bit ARM, where a symlink is provided:

$ adb shell run-as com.steenriver.littlecrane '/system/bin/sh -c "pwd"'
/data/data/com.steenriver.littlecrane
$ adb shell run-as com.steenriver.littlecrane '/system/bin/sh -c "ls -al"'
drwxrwx--x u0_a109  u0_a109           2017-01-18 11:48 app_.gpg.classloader
drwxrwx--x u0_a109  u0_a109           2017-01-18 11:26 cache
drwxrwx--x u0_a109  u0_a109           2017-01-18 11:48 code_cache
drwxrwx--x u0_a109  u0_a109           2017-01-18 11:47 files
lrwxrwxrwx root     root              2017-01-18 11:48 lib -> /data/app/com.steenriver.littlecrane-2/lib/arm
1
  • It's very hard to find information on where SOs are stored in android. It shouldn't have taken as long as it did to find this answer. Thanks
    – chugadie
    Oct 29, 2020 at 11:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.