How to Retrieve the Version Name of an Android Application Using ADB

How to Retrieve the Version Name of an Android Application Using ADB

30 November 2024 Stephan Petzl Leave a comment Tech-Help

When working with Android applications, there might be instances where you need to retrieve the version name of an application directly from your device. This can be particularly useful during testing or when verifying application details across different environments. In this guide, we will explore a straightforward method to achieve this using Android Debug Bridge (ADB).

Retrieving the Version Name

One of the most efficient ways to obtain the version name of an application installed on your Android device is by using the dumpsys command within ADB. Here is a simple command that you can use:

adb shell dumpsys package my.package | grep versionName

This command will quickly return the version name of the specified package. It works by querying the package manager for the application details and filtering the output to display only the version name.

Alternative Methods

For those who might need more detailed information, including both the version code and version name, the following command can be executed:

adb shell dumpsys package | awk '/^[ ]*Package \[.*\] (.*)/ { i = index($0, "[") + 1; pkg = substr($0, i, index($0, "]") - i); } /[ ]*versionName=/ { { print pkg "\t" substr($0, index($0, "=") + 1); pkg = ""; } }'

This script uses awk to process the output, listing all packages along with their version details.

Use Cases

Retrieving application version details can be crucial in scenarios such as:

  • Ensuring compatibility with specific Android OS versions.
  • Verifying the correct version is installed during QA testing.
  • Automating deployment scripts that check dependencies and requirements.

Enhancing Testing with Repeato

For those involved in extensive testing of Android applications, using a tool like Repeato can significantly streamline the process. Repeato is a no-code test automation tool that helps you create, run, and maintain automated tests efficiently. By leveraging computer vision and AI, it offers fast editing and execution of tests. Additionally, Repeato integrates with ADB, allowing you to execute ADB commands through script steps, providing precise control over application testing scenarios.

For more detailed information on setting up virtual test devices or other advanced testing techniques, consider exploring our documentation.

Like this article? there’s more where that came from!