10

I was wondering if it is possible to find all the libraries that are included in the Android project programmatically. I am writing a library which would need info about other libraries included in the project. Any help much appreciated.

RRK
  • 375
  • 3
  • 8
  • There was a similar question which may be helpful to you: http://stackoverflow.com/questions/8740859/how-to-detect-which-native-shared-libraries-are-loaded-by-android-application – mish Jul 24 '13 at 10:52
  • @mish, that is regarding the system's shared libraries. I need the user added libraries. – RRK Jul 25 '13 at 05:19

2 Answers2

0

i have made a simple function, just make a call to this function when you want to have the details.

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...
            }
        }
Anchit Mittal
  • 3,412
  • 4
  • 28
  • 48
  • Thanks for the response. However, the above method lists all the system libraries. I am looking for the user added libraries into the project. Can i improvise on this solution?? – RRK Jul 25 '13 at 05:17
0

For future readers.

You may use Mike Penz's AboutLibraries library

Benefits

  • Allow to list external, internal libraries used in your project
  • Out of box activity or fragment with list of libraries used in your project.
user158
  • 12,852
  • 7
  • 62
  • 94