Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get version information of an included library?

I have an eclipse project with two included library projects. These projects have their own manifest files with version information. Now I want to read the version number from these library projects within my main project. The information can't be read by calling the PackageManager:

//Get the version name from the included library project
String libVersion  = getPackageManager().getPackageInfo("com.google.zxing.client.android", 0).versionName;

Because the library is not an installed application. But what's the right way to get these information?

For instance: I have included zxing Android project as library project. These Project has following version information in its manifest file:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.google.zxing.client.android"
    android:installLocation="auto"
    android:versionCode="88"
    android:versionName="4.3.2" >

I want to read versionCode and versionName. If I use packageManager like in the coding above, I will get versionCode "93" and versionName "4.5".

like image 439
Christian Schulzendorff Avatar asked Oct 16 '13 09:10

Christian Schulzendorff


People also ask

How do I find the version of a file in Linux?

-v, --version Displays the version of the file command.

How do you check whether a library is installed in Ubuntu?

Replace libjpeg by any library you want, and you have a generic, distro-independent* way of checking for library availability. If for some reason the path to ldconfig is not set, you can try to invoke it using its full path, usually /sbin/ldconfig . This should be accepted as the answer.

How do you check if a shared library is loaded in Linux?

To find the list of processes and their loaded libraries, use "genld -ld" command. The -l option reports the lists of loaded objects for each process running on the system.


1 Answers

In fact it is possible now (maybe due to new API changes, tested with API 17 (calling project), API 14 (library project)): if you specifically call the correct package name it will retrieve version information from that packages Manifest file:

eg:

String versionName = getPackageManager().
        getPackageInfo("PACKAGE_FROM_WHICH_TO_RETRIEVE_MANIFEST", 0).versionName;
like image 141
Christopher Hackl Avatar answered Oct 04 '22 21:10

Christopher Hackl