linkUber Adb Tools for Android

A simple tool that makes it more convenient to install, uninstall and creating bug reports and more for multiple apps on multiple devices with one command. Additionally uninstalling allows to use wildcards as package name. This is basically a front-end for the Android Debug Bridge (ADB) which is required to run.

GitHub release Build Status Coverage Status Maintainability

Main features:

Basic usage:

1java -jar uber-adb-tools.jar --install /folder/apks/

2java -jar uber-adb-tools.jar --uninstall com.your.packa*

3java -jar uber-adb-tools.jar --bugreport

More features:

1java -jar uber-adb-tools.jar --force-stop com.your.packa*

2java -jar uber-adb-tools.jar --clear com.your.packa*

3java -jar uber-adb-tools.jar --appinfo com.your.packa*

4java -jar uber-adb-tools.jar --start com.your.packa*

This should run on any Windows, Mac or Linux machine,

linkRequirements

linkDownload

Grab jar from latest Release

linkUsing the *.exe Launcher

logo

Launch4J is used to wrap the .jar into an Windows executable. It should automatically download the needed JRE if required. If a single argument will be passed (ie. a path) the tool will automatically install if it is an .apk (or folder with apks), so you can use it to drag an .apk over the .exe or use it to "Open with..." to automatically install an apk if double clicked.

linkDemo

asciicast

linkCommand Line Interface

The documentation of all possible parameters

1 --adbPath Full path to adb executable. If this is omitted the tool tries to find

2 adb in PATH env variable.

3 --appinfo Will show additional information for like version, install-time, etc of

4 the apps matching the argument. Argument is the filter string that has

5 to be a package name or part of it containing wildcards '*'. Can be

6 multiple filter Strings space separated. Example: 'com.android.*' or

7 'com.android.* com.google.*'.

8-b,--bugreport Creates a generic bug report (including eg. logcat and screenshot) from

9 all connected devices and zips it to the folder given as arg. If no

10 folder is given tries to zips it in the location of the .jar.

11 --clear Will clear app data for given packages. Argument is the filter string

12 that has to be a package name or part of it containing wildcards '*'.

13 Can be multiple filter Strings space separated. Example: 'com.android.*'

14 or 'com.android.* com.google.*'.

15 --debug Prints additional info for debugging.

16 --dryRun Use this to see what would be installed/uninstalled on what devices with

17 the given params. Will not install/uninstall anything.

18 --dumpsysServices Only for bugreport: include only theses dumpsys services. See all

19 services with 'adb shell dumpsys list'

20 --force If this flag is set all matched apps will be installed/uninstalled

21 without any further warning. Otherwise a user input is necessary.

22 --force-stop Will stop the process of given packages. Argument is the filter string

23 that has to be a package name or part of it containing wildcards '*'.

24 Can be multiple filter Strings space separated. Example: 'com.android.*'

25 or 'com.android.* com.google.*'.

26 --grant Only for install: will grant all permissions set in the apk

27 automatically.

28-h,--help Prints docs

29-i,--install Provide path to an apk file or folder containing apk files and the tool

30 tries to install all of them to all connected devices (if not a specfic

31 device is selected). It is possible to pass multiple files/folders as

32 arguments e.g. '/apks apk1.apk apk2.apk'

33 --keepData Only for uninstall: Uses the '-k' param on 'adb uninstall' to keep data

34 and caches of the app.

35 --quiet Prints less output.

36 --reportDebugIntent Only for Bugreport: This is useful to start a e.g. activity that e.g.

37 logs additional info before reading the logcat. First param is a package

38 filter (see --uninstall argument) followed by a series of params

39 appended to a 'adb shell am' type command to start an activity or

40 service (See https://goo.gl/MGK7ck). This will be executed for each

41 app/package that is matched by the first parameter. You can use the

42 placeholder '${package}' and will substitute the package name. Example:

43 'com.google* start -n ${package}/com.myapp.LogActivity --ez LOG true'

44 See https://goo.gl/luuPfz for the correct intent start syntax.

45-s,--serial If this is set, will only use given device. Default is all connected

46 devices. Device id is the same that is given by 'adb devices'

47 --simpleBugreport Only for bugreport: report will only contain the most essential data

48 --skipEmulators Skips device emulators for install/uninstall.

49 --start <[seconds]> Will start the launcher activity of this app. Argument is the filter

50 string that has to be a package name or part of it containing wildcards

51 '*'. Can be multiple filter Strings space separated. Example:

52 'com.android.*' or 'com.android.* com.google.*'. The last argument may

53 be a int in seconds which represents the wait time between the apps eg.:

54 'com.exmaple.* 10' will have a 10 sec delay between starts.

55-u,--uninstall Filter string that has to be a package name or part of it containing

56 wildcards '*' for uninstalling. Can be multiple filter Strings space

57 separated. Example: 'com.android.*' or 'com.android.* com.google.*'.

58 --upgrade Only for install: Uses the '-r' param on 'adb install' for trying to

59 reinstall the app and keeping its data.

60-v,--version Prints current version.

61 --waitForDevice If set, will wait until a device is connected and debug mode is enabled.

linkGeneral

Test what would happen with dryrun:

1java -jar uber-adb-tools.jar --install /myfolder -dryRun

Install/Uninstall only on a certain device by providing the device's serial (check adb devices):

1java -jar uber-adb-tools.jar --uninstall com.your.packa* -s IUG65621532

Skip user prompt:

1java -jar uber-adb-tools.jar --uninstall com.your.packa* --force

Provide your own adb executables:

1java -jar uber-adb-tools.jar --bugreport --adbPath "C:\pathToAdb\adb.exe"

Wait until device is connected:

1java -jar uber-adb-tools.jar --uninstall com.your.packa* --waitForDevice

linkInstall

If the apk is already installed upgrade to new version while keeping the app's data:

1java -jar uber-adb-tools.jar --install /myfolder/my-apk.apk --upgrade

Only install a certain apk file (as opposed to installing all from a folder):

1java -jar uber-adb-tools.jar --install /myfolder/my-apk.apk

Provide multiple files/folder

1java -jar uber-adb-tools.jar --install /myfolder/my-apk.apk /otherfolder /apk1.apk

linkUninstall

Provide more than one package filter:

1java -jar uber-adb-tools.jar --uninstall com.your.packa* com.their.packa* com.third.*

linkWildcard Support for Package Filter

It is possible to just use the full package name like using adb uninstall com.mypackage.app. To take advantage of the enhance features wildcards are supported:

1com.android.*

Will match e.g. com.android.app, com.android.app.maps, com.android.something Will NOT match com.android, org.com.android

1com.android.*e

Will match e.g. com.android.app.service, com.android.elle Will NOT match com.android, com.android.app

1com.android.*.debug

Will match e.g. com.android.app.service.debug, com.android.maps.debug Will NOT match com.android.debug, com.android.app

Note: Wildcard is not supported at the beginning of the package filter

linkBugreport

The idea behind this is to get a smaller faster version of the default adb bugreport that is easier to read and understand as well as customizable and more practical for the "every-day-bug".

linkContent

A full bugreport will contain the following data:

linkExamples

Provide your own dumpsys services

1java -jar uber-adb-tools.jar --bugreport --dumpsysServices package nfc battery

Only log the most essential

1java -jar uber-adb-tools.jar --bugreport --simpleBugreport

Provide a activity intent to start before logcat will be pulled for request apps (packages) while using package placeholder:

1java -jar uber-adb-tools.jar --bugreport --reportDebugIntent your.package.* start -n ${package}/com.company.app.DebugLogActivity --ez HEADLESS true

linkStarting custom intents

When using the --reportDebugIntent argument you first have to provide a package filter string (see uninstall) and then a series of arguments describing the activity/service/etc. to start. These arguments are internally appended to a adb shell am ... command, therefore use the same syntax, eg. start to start an activity with intent params and startservice to start an service. For details on the intent syntax, see https://developer.android.com/studio/command-line/shell.html#IntentSpec.

An example on how to use this:

  1. Create an activity that logs some custom code when a specific flag is set

    1 public class DebugLogActivity extends AWalletActivity {

    2 ...

    3 private static final String KEY_HEADLESS = "HEADLESS"; //used with external programs

    4

    5 @Override

    6 protected void onCreate(Bundle savedInstanceState) {

    7 super.onCreate(savedInstanceState);

    8

    9 if (getIntent().getBooleanExtra(KEY_HEADLESS, false)) {

    10 //TODO add custom log here

    11 finish();

    12 } else {

    13 setContentView(R.layout.activity_layout);

    14 //create here your activity as you normally would if you need ui

    15 }

    16 }

    17 ...

    18 }

In your AndroidManifest declare the activity as exported:

1

2 android:name=".DebugLogActivity"

3 android:label="@string/app_name"

4 android:exported="true">

5

You should now be able to access this feature with adb:

1adb shell am start -n /.AppInfoActivity --ez HEADLESS true

Note: <your_application_id> is what you set in gradle as applicationId and <your_internal_package> is your actual java package (they might be the same)

Now we might have the problem when using multiple flavours, that you want to use this command on multiple apps - you can use a placeholder for this: ${package} so the final bugreport call will look like:

1java -jar uber-adb-tools.jar --bugreport --reportDebugIntent your.package.* start -n ${package}/com.company.app.DebugLogActivity --ez HEADLESS true

linkAdditional Features

Clear app data & caches of all matching apps

1java -jar uber-adb-tools.jar --clear com.example.*

Force stop all matching apps

1java -jar uber-adb-tools.jar --force-stop com.example.*

Show app info (version, install time, etc.) of matched apps

1java -jar uber-adb-tools.jar --appinfo com.example.*

Start all matching apps (launcher activity) with start delay of 9 seconds:

1java -jar uber-adb-tools.jar --start com.your.packa* 9

linkProcess Return Value

This application will return 0 if every install/uninstall was successful, 1 if an error happens (e.g. wrong arguments) and 2 if at least one part of a install/uninstall process was not successful.

linkADB Executable Location Strategy

If you provide a custom location to adb, the tool will try to use it. Otherwise it will try to use the one provided by the system, which requires adb to be set in PATH (See http://stackoverflow.com/questions/20564514 ). As a fallback, if the tool does not find the adb in PATH it tries to check some default locations for the Android SDK. One of these default location checks involves checking if ANDROID_HOME is set, so if you don't want to set adb in PATH, use ANDROID_HOME environment variable.

linkUsed ADB commands

This tool uses the following adb commands:

adb devices -l Gathers the attached devices. May use the -s param with a device's serial.

adb shell "pm list packages -f" List all installed packages. May use the -s param with a device's serial.

adb shell pm uninstall <package> Uninstalls an app.

adb install <apk-file> Installs an app.

linkDigital Signatures

linkSigned Jar

The provided JARs in the Github release page are signed with my private key:

1CN=Patrick Favre-Bulle, OU=Private, O=PF Github Open Source, L=Vienna, ST=Vienna, C=AT

2Validity: Thu Sep 07 16:40:57 SGT 2017 to: Fri Feb 10 16:40:57 SGT 2034

3SHA1: 06:DE:F2:C5:F7:BC:0C:11:ED:35:E2:0F:B1:9F:78:99:0F:BE:43:C4

4SHA256: 2B:65:33:B0:1C:0D:2A:69:4E:2D:53:8F:29:D5:6C:D6:87:AF:06:42:1F:1A:EE:B3:3C:E0:6D:0B:65:A1:AA:88

Use the jarsigner tool (found in your $JAVA_HOME/bin folder) folder to verify.

linkSigned Commits

All tags and commits by me are signed with git with my private key:

1GPG key ID: 4FDF85343912A3AB

2Fingerprint: 2FB392FB05158589B767960C4FDF85343912A3AB

linkBuild

linkJar Sign

If you want to jar sign you need to provide a file keystore.jks in the root folder with the correct credentials set in environment variables ( OPENSOURCE_PROJECTS_KS_PW and OPENSOURCE_PROJECTS_KEY_PW); alias is set as pfopensource.

If you want to skip jar signing just change the skip configuration in the pom.xml jar sign plugin to true:

1true

linkBuild with Maven

Use the Maven wrapper to create a jar including all dependencies

1mvnw clean package

linkCheckstyle Config File

This project uses my common-parent which centralized a lot of the plugin versions aswell as providing the checkstyle config rules. Specifically they are maintained in checkstyle-config. Locally the files will be copied after you mvnw install into your target folder and is called target/checkstyle-checker.xml. So if you use a plugin for your IDE, use this file as your local configuration.

linkTech Stack

linkCredits

linkLicense

Copyright 2016 Patrick Favre-Bulle

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

1http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Star
Uber Adb Tools for AndroidRequirementsDownloadUsing the *.exe LauncherDemoCommand Line InterfaceGeneralInstallUninstallWildcard Support for Package FilterBugreportContentExamplesStarting custom intentsAdditional FeaturesProcess Return ValueADB Executable Location StrategyUsed ADB commandsDigital SignaturesSigned JarSigned CommitsBuildJar SignBuild with MavenCheckstyle Config FileTech StackCreditsLicense

Home

OpenSourcechevron_right



Patrick Favre-Bulle 2020