Alin
Alin

Reputation: 14571

Android NDK cpp library where is located and where is loaded?

I have a simple cpp library which returns a string value. This was made similar as in the https://developer.android.com/studio/projects/add-native-code.html

After building the apk, after analyzing it I see a lib folder which contains .so files for different ABIs.

My questions is: since the generated files are included in the apk itself, from where and to where does System.loadLibary(String) take action? Is the library file within the private app's folder and only accessible to the app, after it's being loaded? Do other apps have access to this library once it has been loadLibrary in my app? Is it copied somewhere in the android system folder?

Upvotes: 0

Views: 94

Answers (1)

Gustav Pihl
Gustav Pihl

Reputation: 28

Loads the dynamic library with the specified library name. A file containing native code is loaded from the local file system from a place where library files are conventionally obtained. The details of this process are implementation-dependent. The mapping from a library name to a specific filename is done in a system-specific manner.

Source: https://developer.android.com/reference/java/lang/Runtime.html#loadLibrary(java.lang.String)

The library is not copied to a shared location when it is loaded. Loading a library means its symbols are linked to native methods.

Upvotes: 1

Related Questions