如何以编程方式知道Android项目中包含哪些库?

RRK*_*RRK 10 android libraries

我想知道是否有可能以编程方式找到Android项目中包含的所有库.我正在编写一个库,需要有关项目中包含的其他库的信息.任何帮助非常感谢.

Anc*_*tal 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...
            }
        }
Run Code Online (Sandbox Code Playgroud)