在我的项目中,我已经包含了用户创建的库。我想检查项目中是否存在库。 我是怎么做到的?
答案 0 :(得分:0)
以下代码可能会有所帮助
public static void checkLibrary(){
try {
Log.e(" i am in","checklibrary");
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.e("Ldd", libs.size() + " libraries:");
for (String lib : libs) {
Log.e("Ldd", lib);
}
} catch (FileNotFoundException e) {
// Do some error handling...
} catch (IOException e) {
// Do some error handling...
}
}