Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get version information of an included library?

Tags:

android

I have created 2 project 1 is Lib and 2nd in Test. From test app I pass context to Lib project.

As I have context in Lib, i used below code inside Lib

String version = this.mContext.getPackageManager().getPackageInfo(this.mContext.getPackageName(), 0).versionName; Log.e("versionName", version);

But this gives me version name of test app and not lib. How should i get application version name and code for Lib?

Reference link: How to get version information of an included library?

like image 838
morya Avatar asked Jul 18 '14 18:07

morya


People also ask

How do I tell what version of a library is installed?

Or from the command line, you can first search for the name of the associated package using dpkg -S /usr/lib/libnuma. so. 1 , which probably returns libnuma1 as the package name. Then run apt-cache showpkg libnuma1 to find the package version.

How do I find the version of an .so file?

As far as ELF is concerned, there is no version information of Shared object stored in the file. So unless the file name itself is saying something like "libXXX.VERSION.so" , there is no other way to find out the version number of the shared object. This technique is generally used in Linux.

How do you check version of .so file in Linux?

We explained how to find and display the OS version on Linux. The safest option is to query /etc/os-release file using grep or cat command. Systemd based Linux distro users can use the hostnamectl command.


1 Answers

BuildConfig.VERSION_NAME

Just make sure that you import the BuildConfig for your library (as literally every android library/app has it's own BuildConfig on it's package path). The Android Studio's Gradle Build system indicates that this is always generated as of version 0.7.0 (see changelog).

like image 140
JCricket Avatar answered Nov 01 '22 16:11

JCricket