Get The Version Of A Library In My Android App Programmatically
Solution 1:
That won’t work, PackageManager APIs help you check for any valid packages/apps installed using a package name lookup.
Since the library is in the class path for your own package the only way to reference these ids at runtime would be to have a workflow to record these during compilation and expose it to your application at runtime.
Following approaches are viable:
Expose library metadata in build config/resources (https://developer.android.com/studio/build/gradle-tips#simplify-app-development)
Custom gradle plugin to capture all libraries in classpath into assets which can be read at runtime, something similar to https://github.com/google/play-services-plugins
With (1) you can’t scale it for multiple libraries conveniently so it’s only useful for very specific needs.
(2) might require some customisations for your usecase (adding version info) but is definitely scalable.
Post a Comment for "Get The Version Of A Library In My Android App Programmatically"