cancel
Showing results for 
Search instead for 
Did you mean: 

Get version of installed Android application

SOLVED
Contributor

Get version of installed Android application

Hi

 

I would like to log the version of the current Android application under test. I can't seem to figure out how to do it. Is it possible? I know you can get lots of application information when testing iOS, but I can't find anything similar for Android.

 

Best regards

Lars Lund Olsen

1 ACCEPTED SOLUTION

Accepted Solutions
Community Hero

Re: Get version of installed Android application

Hi Lars,

 

To get version of the application installed on the Android device using TestComplete:

-- Get list of the installed applications with the code like this (DelphiScript):

  DeviceObj := Mobile.Device();
  PackManagerObj := DeviceObj.PackageManager;
  Num := PackManagerObj.InstalledPackageCount;

  for i := 0 to Num - 1 do
  begin
    Log.AppendFolder(i);
    PackObj := PackManagerObj.InstalledPackage(i);
    // Obtain the package name
    Log.Message('The package name is: ' + PackObj.Name);
    // Obtain the path to the package on the local computer
    Log.Message('The package local path is: ' + PackObj.PCPath);
    // Obtain the path to the package on the device
    Log.Message('The package device path is: ' + PackObj.DevicePath);

    if (PackManagerObj.IsActivePackage(PackObj)) then
      Log.Message('The specified package is active.')
    else
      Log.Message('The specified package is not active.');

    Log.PopLogFolder();
  end;

and get the package name from there;

 

-- Execute code line like this:

str := Mobile.Device.ShellExecute('dumpsys package <package_name> | grep versionName');

the above line of code should return the string like

versionName=2.0.2.11

 

-- Get version number from the above string.

 

 

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Postings made by [Community Expert Group] members
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================
4 REPLIES 4
Community Hero

Re: Get version of installed Android application

Hi Lars,

 

To get version of the application installed on the Android device using TestComplete:

-- Get list of the installed applications with the code like this (DelphiScript):

  DeviceObj := Mobile.Device();
  PackManagerObj := DeviceObj.PackageManager;
  Num := PackManagerObj.InstalledPackageCount;

  for i := 0 to Num - 1 do
  begin
    Log.AppendFolder(i);
    PackObj := PackManagerObj.InstalledPackage(i);
    // Obtain the package name
    Log.Message('The package name is: ' + PackObj.Name);
    // Obtain the path to the package on the local computer
    Log.Message('The package local path is: ' + PackObj.PCPath);
    // Obtain the path to the package on the device
    Log.Message('The package device path is: ' + PackObj.DevicePath);

    if (PackManagerObj.IsActivePackage(PackObj)) then
      Log.Message('The specified package is active.')
    else
      Log.Message('The specified package is not active.');

    Log.PopLogFolder();
  end;

and get the package name from there;

 

-- Execute code line like this:

str := Mobile.Device.ShellExecute('dumpsys package <package_name> | grep versionName');

the above line of code should return the string like

versionName=2.0.2.11

 

-- Get version number from the above string.

 

 

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Postings made by [Community Expert Group] members
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================
Contributor

Re: Get version of installed Android application

Thank you very much! It was exactly what I was after. And thanks for pointing me to the Dumpsys command, that will be useful in other contexts as well :-)

 

Best regards

Lars Lund Olsen

Community Hero

Re: Get version of installed Android application

Great, thank you for the prompt update, Lars Smiley Happy

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Postings made by [Community Expert Group] members
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================
Frequent Visitor

Re: Get version of installed Android application

Active office on my phone
Tags (1)
New Here?
Join us and watch the welcome video:
Watch the new Interview
Top Kudoed Authors