My application uses native shared library (.so), I am loading it by calling System.loadLibrary(\"xxx\")
. It loads fine and I can call the native methods.
Use this code to list the shared native libraries that can be loaded from your app:
final File nativeLibraryDir = new File(getApplicationInfo().nativeLibraryDir);
final String[] primaryNativeLibraries = nativeLibraryDir.list();
The solution is simple, many thanks to @ praetorian-droid
try {
Set<String> libs = new HashSet<String>();
String mapsFile = "/proc/" + android.os.Process.myPid() + "/maps";
BufferedReader reader = new BufferedReader(new FileReader(mapsFile));
String line;
while ((line = reader.readLine()) != null) {
if (line.endsWith(".so")) {
int n = line.lastIndexOf(" ");
libs.add(line.substring(n + 1));
}
}
Log.d("Ldd", libs.size() + " libraries:");
for (String lib : libs) {
Log.d("Ldd", lib);
}
} catch (FileNotFoundException e) {
// Do some error handling...
} catch (IOException e) {
// Do some error handling...
}