Android has a neat software accessible to builders known as the Android Debug Bridge, or ADB for brief. It’s utilized in Android Studio and manually by Android builders to put in and take a look at apps on Android smartphones and emulated Android units.
However there’s loads ADB can do, and most of it isn’t solely helpful to builders. Even if you happen to aren’t a developer and also you’re studying this text, there’s a superb probability you’ve most likely used ADB a few times to put in an app or tweak a permission. However that isn’t all ADB can be utilized for. Hold studying for some ideas and tips for utilizing ADB you may not have recognized about.
When you’ve used ADB earlier than, you could be used to operating instructions multi functional line. However you too can use ADB to open a terminal shell in your machine and run instructions instantly. And it’s straightforward!
In your terminal or command immediate window:
You’ll then be greeted with a
$ image the place you may run instructions instantly in your machine.
Itemizing Put in Apps by way of ADB
To see the put in apps in your machine, you should use the next command:
adb shell pm checklist packages
This may return an inventory of the bundle names of the put in apps, with each by itself line prepended with
There are additionally some choices you should use to retrieve extra particular lists.
- -f will embrace the trail to the bottom APK for every app, together with its bundle identify.
- -a will be sure all recognized non-APEX packages are returned.
- -d will trigger the command to solely return disabled packages.
- -e will trigger the command to solely return enabled packages.
- -s will trigger the command to solely return system packages.
- -3 will trigger the command to solely return third-party packages.
- -i will embrace the installer bundle identify for every bundle.
- -U will embrace the bundle UID for every bundle.
- -u will embrace uninstalled packages.
- –show-versioncode will embrace the model code for every bundle.
- –apex-only will solely return APEX packages.
- –uid <UID> will solely present packages with the given UID.
- –person <USER_ID> will solely present packages belonging to the given person ID.
Putting in & Uninstalling Apps by way of ADB
It is a comparatively widespread use of ADB, but it surely’s value mentioning anyway. Amongst different methods, you too can make use of ADB to set up and uninstall Android apps to your Android machine.
Putting in an APK
If in case you have an APK in your pc, you may set up it to your machine with the next:
adb set up -r someapk.apk
Bear in mind to switch
someapk.apk with the total path to the APK you need to set up.
There are a bunch of choices for putting in APKs by way of ADB.
- The -r possibility permits ADB to put in over an present app (i.e., replace). On Android Pie and later, you don’t should specify this selection.
- The -R possibility, for Android Pie and later, will trigger the set up to fail if the app is already put in.
- The -i possibility enables you to specify an installer bundle identify. That is what will get returned if Android needs to know what put in the APK.
- The -t possibility permits an APK with android:testOnly=”true” in its manifest to be put in.
- The -d possibility permits the desired APK to be a downgrade to an already-installed app. This solely works if each variations of the app are debuggable.
- The -g possibility for Android Marshmallow and later routinely grants all runtime permissions to the put in app.
That’s not all of them. If you need a full checklist, you may take a look at the built-in documentation.
A number of APKs and Bundles
If in case you have a bunch of APKs you need to set up without delay, both from a number of apps, or since you’re putting in an app bundle, you should use ADB’s
If all your APKs are for one app, use
adb install-multiple apk1.apk apk2.apk ...
In any other case, use
adb install-multi-package app1.apk app2.apk ...
The choices for these instructions are just like
set up, however with some limitations. Take a look at ADB’s built-in documentation for which choices can be found.
Uninstalling an App
To uninstall utilizing ADB, you’ll want the bundle identify of the app you need to uninstall. Take a look at the part for Itemizing Put in Apps if you happen to haven’t already.
Upon getting the bundle identify, uninstalling is so simple as:
adb uninstall <packagename>
Observe: You usually can’t uninstall system or preinstalled apps utilizing this command. You might be able to disable them with ADB, nonetheless. Take a look at the part Disabling & Enabling nearly any App for particulars.
Extracting APKs with ADB
There are many causes you may need to extract the APK(s) for an app. Perhaps you need to again it up for future use, or possibly it’s not accessible on-line and also you need to switch it to a distinct machine.
Extracting an app utilizing ADB is fairly easy. First, you’ll need to discover the bundle identify of the app you need to extract. There are a number of methods to do that, however the best is often to make use of your machine’s Settings app to view the checklist of all put in apps, choose the one you need, and scroll down till you discover the bundle identify or app ID.
Upon getting the bundle identify, run the next command:
adb shell pm path <packagename>
This command will return the trail of all APKs for that bundle identify.
You may then use the next command to tug every APK to your pc:
adb pull /path/to/apk.apk
Itemizing App Elements
An app’s elements are issues like its Actions, BroadcastReceivers, Companies, and so forth. Typically it’s helpful to know the names of those elements in a selected app, particularly if you wish to launch hidden Actions or ship a broadcast with particular knowledge.
Sadly, ADB doesn’t have a really clear manner of itemizing an app’s elements. However it’s attainable. Run the next command:
adb shell dumpsys bundle <packagename>
A complete bunch of textual content can be returned.
- Scroll till you discover the Exercise Resolver Desk title to see the Actions.
- Look beneath Receiver Resolver Desk for BroadcastReceivers.
- Verify the Service Resolver Desk for Companies.
- And so forth.
Every element will present the motion wanted to launch it, the identify of the element, and probably some further info.
Alternatively, in order for you a neater solution to see Actions, Companies, and Receivers, you should use my Root Exercise Launcher app. It’s going to present you these elements for every app, together with a bunch of different useful options.
Launching Actions, Companies, and BroadcastReceivers
ADB may also be used to launch Actions, begin Companies, and notify BroadcastReceivers. You may even specify knowledge URIs and Intent extras if wanted.
To launch elements, you’ll want the element identify of what you need to launch. You may see the way to get that from the Itemizing App Elements part.
The command syntax for launching an Exercise is one thing like this:
am begin -a <motion> -n <element>
The command syntax for beginning a Service is one thing like this:
am startservice -a <motion> -n <element>
The command syntax for notifying a BroadcastReceiver is one thing like this:
am broadcast -a <motion> -n <element>
Typically, for Actions and Companies, you don’t have to explicitly specify an motion. You’ll often solely want it if the element makes use of one aside from android.intent.motion.MAIN.
On prime of the essential syntax, right here’s the way to specify extra knowledge to move. Normally, all knowledge values must be enclosed in double quotes.
- -d means that you can specify an information URI.
- -e <key> <worth> or –es <key> <worth> means that you can specify a String further.
- –esn <key> means that you can specify a null String further.
- –ez <key> <worth> is used to specify a boolean further.
- –ei <key> <worth> is used to specify an integer further.
- –el <key> <worth> is for specifying an extended further.
- –ef <key> <worth> will move a float further.
- –eu <key> <worth> passes a URI further.
- –ecn <key> <worth> can be utilized to specify a element identify further.
- –eia <key> <value1>,<value2>,… will move the values as an Integer further.
- –eial <key> <value1>,<value2>,… will move the values as a Checklist<Integer>.
- The identical array and checklist arguments additionally work for longs, floats, and Strings. Simply exchange the i with the suitable letter.
- -f means that you can specify a flag.
There are much more habits choices you should use, so take a look at the construct in documentation for particulars.
Disabling & Enabling nearly any App
System apps in Android can’t be uninstalled, and plenty of them can also’t be disabled by way of Settings. Whereas ADB received’t allow you to uninstall them, it could aid you disable them.
First, be sure to get the bundle identify of the app you need to disable. Then, strive these instructions. If one fails, strive the following possibility.
- pm disable <bundle>
- To re-enable, use pm allow <bundle>
- pm disable-user –person 0 <bundle>
- To re-enable, use pm allow <bundle>
- pm conceal <bundle>
- To re-enable, use pm unhide <bundle>
- pm droop <bundle>
- To re-enable, use pm unsuspend <bundle>
- pm uninstall -k –person 0 <bundle>
- To re-enable, use pm install-existing <bundle>
- Observe: This one successfully uninstalls the appliance out of your person profile. Whereas the command to re-enable ought to work, there’s no assure it would. Chances are you’ll have to manufacturing unit reset to revive the app.
When you’re utilizing a number of person profiles in your machine, be sure to switch 0 within the instructions above with the precise person ID you’ve.
ADB is an extremely highly effective software, and it could accomplish that way more than simply what’s above. The instructions on this article are only a helpful start line. For extra superior utilization, take a look at instructions like cmd -l to see completely different providers you may have the ability to work together with or ls -l /system/bin to see the completely different command executables accessible.