ADB instructions that each energy consumer ought to learn about!
Android has a neat instrument accessible to builders referred to as the Android Debug Bridge, or ADB for brief. It’s utilized in Android Studio and manually by Android builders to put in and check apps on Android smartphones and emulated Android gadgets.
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 very good likelihood 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. Preserve studying for some ideas and methods for utilizing ADB you may not have recognized about.

Shell Entry
For those who’ve used ADB earlier than, it’s possible you’ll be used to operating instructions multi function line. However you can even use ADB to open a terminal shell in your system and run instructions instantly. And it’s straightforward!
In your terminal or command immediate window:
adb shell
You’ll then be greeted with a $ image the place you’ll be able to run instructions instantly in your system.
![]()
Itemizing Put in Apps by way of ADB
To see the put in apps in your system, you should utilize the next command:
adb shell pm record packages
This may return an inventory of the bundle names of the put in apps, with every one by itself line prepended with bundle:.

Choices
There are additionally some choices you should utilize to retrieve extra particular lists.
- -f will embody the trail to the bottom APK for every app, together with its bundle title.
- -a will be certain that 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 embody the installer bundle title for every bundle.
- -U will embody the bundle UID for every bundle.
- -u will embody uninstalled packages.
- –show-versioncode will embody the model code for every bundle.
- –apex-only will solely return APEX packages.
- –uid <UID> will solely present packages with the given UID.
- –consumer <USER_ID> will solely present packages belonging to the given consumer ID.
Putting in & Uninstalling Apps by way of ADB
It is a comparatively widespread use of ADB, however it’s value mentioning anyway. Amongst different methods, you can even make use of ADB to set up and uninstall Android apps to your Android system.
Putting in an APK
You probably have an APK in your laptop, you’ll be able to set up it to your system with the next:
adb set up -r someapk.apk
Bear in mind to exchange someapk.apk with the total path to the APK you wish to set up.
Choices
There are a bunch of choices for putting in APKs by way of ADB.
- The -r choice permits ADB to put in over an current app (i.e., replace). On Android Pie and later, you don’t need to specify this feature.
- The -R choice, for Android Pie and later, will trigger the set up to fail if the app is already put in.
- The -i choice permits you to specify an installer bundle title. That is what will get returned if Android needs to know what put in the APK.
- The -t choice permits an APK with android:testOnly=”true” in its manifest to be put in.
- The -d choice 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 choice for Android Marshmallow and later mechanically grants all runtime permissions to the put in app.
That’s not all of them. If you’d like a full record, you’ll be able to take a look at the built-in documentation.
A number of APKs and Bundles
You probably have a bunch of APKs you wish to set up directly, both from a number of apps, or since you’re putting in an app bundle, you should utilize ADB’s install-multiple and install-multi-package options.
If all your APKs are for one app, use install-multiple:
adb install-multiple apk1.apk apk2.apk ...
In any other case, use install-multi-package:
adb install-multi-package app1.apk app2.apk ...
The choices for these instructions are much 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 title of the app you wish to uninstall. Take a look at the part for Itemizing Put in Apps if you happen to haven’t already.
After you have the bundle title, uninstalling is so simple as:
adb uninstall <packagename>
Be aware: You usually can’t uninstall system or preinstalled apps utilizing this command. You could possibly 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 wish to extract the APK(s) for an app. Perhaps you wish to again it up for future use, or perhaps it’s now not accessible on-line and also you wish to switch it to a special system.
Extracting an app utilizing ADB is fairly easy. First, you’ll wish to discover the bundle title of the app you wish to extract. There are a number of methods to do that, however the best is often to make use of your system’s Settings app to view the record of all put in apps, choose the one you need, and scroll down till you discover the bundle title or app ID.
After you have the bundle title, run the next command:
adb shell pm path <packagename>
This command will return the trail of all APKs for that bundle title.

You’ll be able to then use the next command to tug every APK to your laptop:
adb pull /path/to/apk.apk
Itemizing App Elements
An app’s elements are issues like its Actions, BroadcastReceivers, Providers, 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 information.
Sadly, ADB doesn’t have a really clear approach of itemizing an app’s elements. However it’s doable. 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 below Receiver Resolver Desk for BroadcastReceivers.
- Examine the Service Resolver Desk for Providers.
- And so forth.
Every part will present the motion wanted to launch it, the title of the part, and presumably some additional info.

Alternatively, in order for you a better option to see Actions, Providers, and Receivers, you should utilize my Root Exercise Launcher app. It is going to present you these elements for every app, together with a bunch of different helpful options.
Launching Actions, Providers, and BroadcastReceivers
ADB will also be used to launch Actions, begin Providers, and notify BroadcastReceivers. You’ll be able to even specify information URIs and Intent extras if wanted.
To launch elements, you’ll want the part title of what you wish to launch. You’ll be able to see easy methods 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 <part>
The command syntax for beginning a Service is one thing like this:
am startservice -a <motion> -n <part>
The command syntax for notifying a BroadcastReceiver is one thing like this:
am broadcast -a <motion> -n <part>
Typically, for Actions and Providers, you don’t have to explicitly specify an motion. You’ll often solely want it if the part makes use of one aside from android.intent.motion.MAIN.
On high of the essential syntax, right here’s easy methods to specify extra information to move. Normally, all information values must be enclosed in double quotes.
- -d permits you to specify an information URI.
- -e <key> <worth> or –es <key> <worth> permits you to specify a String additional.
- –esn <key> permits you to specify a null String additional.
- –ez <key> <worth> is used to specify a boolean additional.
- –ei <key> <worth> is used to specify an integer additional.
- –el <key> <worth> is for specifying an extended additional.
- –ef <key> <worth> will move a float additional.
- –eu <key> <worth> passes a URI additional.
- –ecn <key> <worth> can be utilized to specify a part title additional.
- –eia <key> <value1>,<value2>,… will move the values as an Integer[] additional.
- –eial <key> <value1>,<value2>,… will move the values as a Checklist<Integer>.
- The identical array and record arguments additionally work for longs, floats, and Strings. Simply change the i with the suitable letter.
- -f permits you to specify a flag.
There are much more habits choices you should utilize, 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 a whole lot of them can also’t be disabled by way of Settings. Whereas ADB received’t allow you to uninstall them, it might enable you to disable them.
First, be certain that to get the bundle title of the app you wish to disable. Then, strive these instructions. If one fails, strive the following choice.
- pm disable <bundle>
- To re-enable, use pm allow <bundle>
- pm disable-user –consumer 0 <bundle>
- To re-enable, use pm allow <bundle>
- pm cover <bundle>
- To re-enable, use pm unhide <bundle>
- pm droop <bundle>
- To re-enable, use pm unsuspend <bundle>
- pm uninstall -k –consumer 0 <bundle>
- To re-enable, use pm install-existing <bundle>
- Be aware: This one successfully uninstalls the appliance out of your consumer profile. Whereas the command to re-enable ought to work, there’s no assure it can. You might have to manufacturing unit reset to revive the app.
For those who’re utilizing a number of consumer profiles in your system, be certain that to exchange 0 within the instructions above with the precise consumer ID you might have.
ADB is an extremely highly effective instrument, and it might achieve this far more than simply what’s above. The instructions on this article are only a helpful place to begin. For extra superior utilization, take a look at instructions like cmd -l to see totally different companies you may be capable of work together with or ls -l /system/bin to see the totally different command executables accessible.
from WordPress https://ift.tt/3CKjwr1
Comenta