当前位置: 动力学知识库 > 问答 > 编程问答 >

Why is my Android lib dir symlink incorrect?

问题描述:

I'm making an Android app whose native NDK code dynamically links some .so shared library files with dlopen() (if you're interested, it's the OpenNI2 camera library that first detects which camera model is attached and then loads an .so file for that model).

I've placed these libraries in my app/src/main/jniLibs/armeabi-v7a/ directory (for my phone running API version 19 on ARM) and app/src/main/jniLibs/x86_64/ directory (for my tablet running API version 23 on Intel x86_64).

On the ARM, everything works fine, and the symlink to the lib directory containing my .so files is correct:

# ls -l /data/data/com.example/

drwxrwx--x u0_a175 u0_a175 2015-09-02 00:10 app_execdir

drwxrwx--x u0_a175 u0_a175 2015-09-19 22:39 cache

lrwxrwxrwx install install 2015-09-20 02:30 lib -> /data/app-lib/com.example-1

# ls -l /data/app-lib/com.example-1

-rwxr-xr-x system system 409940 2015-10-20 02:30 gdbserver

-rwxr-xr-x system system 308532 2015-10-18 01:06 libOpenNI2.so

However, on the Intel I see:

# ls -l /data/data/com.example/

drwxrwx--x u0_a65 u0_a65 2015-09-20 00:41 app_execdir

drwxrwx--x u0_a65 u0_a65 2015-09-20 00:41 cache

lrwxrwxrwx install install 2015-09-20 00:41 lib -> /data/app-lib/com.example

# ls -l /data/app-lib/com.example

/data/app-lib/com.example: No such file or directory

What's going on here? Why does the lib symlink point to a directory that doesn't exist?

How can I fix it?

网友答案:

It doesn't make sense for the symlink...

However .so files shouldn't be in /data/app-lib/ with Android 21+. Can you find your libs inside /data/app/com.example-1/lib/x86_64 ?

You can read legacyNativeLibraryDir from dumpsys package packages to know where the libs should be placed.

分享给朋友:
您可能感兴趣的文章:
随机阅读: