Skip to content
QiTASC.com / UI Steps Language /
APK Management
/ .. /
APK Management





APK Management

The following instructions show how to find a package's name and how to update the APK version from the command line. For creating custom steps that can find, install and uninstall APKs, refer to the ADB Built-ins.

APK Management
Issue Commands to a Specific Phone
Find the Package Name
Update the APK Version

Issue Commands to a Specific Phone

In some cases (for example, when installing an APK), a particular phone must be specified. This is achieved by passing the -s parameter followed by the device's serial number.

Syntax

1
adb -s <serialNumber Number> <command String>

Parameters

  • serialNumber - The serial number of the device being targeted

  • command - The ADB command

Example

1
2
3
adb -s 01abc2de345fgh678 shell pm list packages

adb -s 01abc2de345fgh678 install selendroid-test-app-0.10.0.apk

Find the Package Name

If the required APK is not in the APK folder, find the package name and remove its signature. If the package name is unknown, the following steps can be used.

Important! When using Appium, the APK signature must not be removed.

1. Check if ADB Connects to the Phone

Running adb devices from the command line shows all devices connected to the machine. If there are multiple phones connected and a specific phone's APK is required, disconnect any unneeded phones for the duration of the testing.

Procedure

  • Connect the phone via USB to the computer.

  • Open a Terminal/Command Prompt window and enter the command adb devices, which will display the phone's serial number on the left side and whether or not it is connected on the right.

  • If the result is blank, ensure that developer mode is active and the USB Debugging is checked:

  • To activate developer mode, go to Settings -> About Phone and click the Build Number tab seven times.

  • Navigate back to Settings -> About Phone. The Developer Options tab will appear.

  • In Developer Options, check the USB Debugging box. Then run adb devices in the Terminal.

Depending on the OS, additional steps may be required. These can be found on the Android Debug Bridge webpage.

2. Get the Package's Name

There are two ways to get the package's name.

Option 1 Enter the following command into a Terminal/Command Prompt:

1
adb shell pm list packages
This will show a list of all packages on the phone.

In order to configure more than one phone, ensure they are all connected and recognized by ADB. Then add -s <Serialnumber> to each command for each phone. This addresses a specific phone:

1
adb -s 01abc2de345fgh678 shell pm list packages

Important! The above commands must be entered for each phone that will be executing tests.

Option 2 Manually start the required application on the phone and then enter the following command into a shell:

Windows User

1
adb shell dumpsys window windows | findstr /r "mCurrentFocus mFocusedApp"

Linux/ Mac OS User

1
adb shell dumpsys window windows | grep -E 'mCurrentFocus|mFocusedApp'

This will generate a result that may look similar to the one below:

1
2
3
4
5
6
mCurrentFocus=Window{32d160e u0
com.qitasc.android.qitasccompanion/com.qitasc.android.qitasccompanion.ui.activity.
MainActivity}
mFocusedApp=AppWindowToken{2cb79f26 token=Token{6775281
ActivityRecord{1f809e68 u0 com.qitascweb.android.qitascwebquicksearchbox
/com.qitascweb.android.launcher.GEL t3256}}

In the example above, the text before the first /com.qitasc.android.qitasccompanion is the package's name.

3. Temporarily Save the APK

Temporarily save the application and retrieve its path from the command line:

Syntax

1
adb shell pm path <APKName Name>

Parameter

  • APKName - The APK name

Example

1
adb shell pm path com.qitasc.android.qitasccompanion

Copy the path and paste it after the following command: Syntax

1
adb pull <ApkPath Url>

Parameter

  • ApkPath - The path to where the APK file is temporarily saved

Example

1
adb pull /data/app/com.qitasc.android.qitasccompanion-1/base.APK

4. Remove the Signature (Selendroid Only)

Remove the signature if using Selendroid. Otherwise, it will not work. Windows users will first have to get the ZIP file from Stahlworks here and save the unzipped folder into the same folder as the Aoks.

Syntax

1
zip -d <YourApk.apk> 'META-INF/.SF' 'META-INF/.RSA' 'META-INF/*SF'
Parameter

  • YourApk.apk - The APK's identifier, including the file extension .apk

Example

1
zip -d base.apk 'META-INF/.SF' 'META-INF/.RSA' 'META-INF/*SF'

Important! When using Appium, the APK signature must not be removed.

5. Save the APK File

After removing the signature, the APK file can be saved into its designated folder.

Update the APK Version

If a newer version of an app will be tested, the APK version must also be updated. The old version of the app and its Selendroid driver app must first be removed, otherwise, intaQt may continue testing an older version.

Find the Package Name

The following command will list two packages: one with the package name and one prepended with io.selendroid followed by the package's name.

Syntax

1
adb -s <serialNr Number> shell pm list packages | grep <appName Name>

Parameters

  • serialNr - The device's serial number

  • appName - The app's name

Example

1
adb shell pm list packages | grep socialapp

This could return:

1
2
package:io.selendroid.socialapp
package:socialapp

Remove the Packages

1
2
adb -s <serialNr Number> uninstall <packageName Name>
adb -s <serialNr Number> uninstall io.selendroiid.<packageName Name>

Parameters

  • serialNr - The device's serial number

  • appName - The app's name

Example

1
2
adb -s FUD6-X59P-TNA7 uninstall <packageName Name>
adb -s GJ8J-VUGQ-7BJX uninstall io.selendroiid.<packageName Name>