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".
-v, --version Displays the version of the file command.
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.
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.
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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With