Reviews

ADB Suggestions & Methods: ADB instructions that each energy consumer ought to learn about!

Related Articles

Android has a neat device accessible to builders known as the Android Debug Bridge, or ADB for brief. It is 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 lots ADB can do, and most of it is not solely helpful to builders. Even in the event you aren’t a developer and also you’re studying this text, there is a good probability you have most likely used ADB a few times to put in an app or tweak a permission. However that is not all ADB can be utilized for. Hold studying for some suggestions and tips for utilizing ADB you may not have recognized about.

Observe: You will have to have ADB up and working in your pc. Remember to try our article on the right way to set up ADB in the event you need assistance.



Shell Entry

In the event you’ve used ADB earlier than, chances are you’ll be used to working instructions multi function line. However it’s also possible to use ADB to open a terminal shell in your gadget and run instructions instantly. And it is easy!

In your terminal or command immediate window:

adb shell

You will then be greeted with a $ image the place you’ll be able to run instructions instantly in your gadget.

An ADB Shell


Itemizing Put in Apps via ADB

To see the put in apps in your gadget, you need to use the next command:

adb shell pm record packages

It will return an inventory of the package deal names of the put in apps, with every one by itself line prepended with package deal:.

ADB Shell listing of installed packages

Choices

There are additionally some choices you need to use to retrieve extra particular lists.

  • -f will embody the trail to the bottom APK for every app, together with its package deal title.
  • -a will ensure 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 package deal title for every package deal.
  • -U will embody the package deal UID for every package deal.
  • -u will embody uninstalled packages.
  • –show-versioncode will embody the model code for every package deal.
  • –apex-only will solely return APEX packages.
  • –uid <UID> will solely present packages with the given UID.
  • –user <USER_ID> will solely present packages belonging to the given consumer ID.


Putting in & Uninstalling Apps via ADB

This can be a comparatively frequent use of ADB, but it surely’s value mentioning anyway. Amongst different methods, it’s also possible to make use of ADB to put in and uninstall Android apps to your Android gadget.

Putting in an APK

If in case you have an APK in your pc, you’ll be able to set up it to your gadget with the next:

adb set up -r someapk.apk

Keep in mind to interchange someapk.apk with the complete path to the APK you wish to set up.

Choices

There are a bunch of choices for putting in APKs via ADB.

  • The -r possibility permits ADB to put in over an current app (i.e., replace). On Android Pie and later, you do not have to 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 package deal title. 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 required 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 is not all of them. If you’d like a full record, you’ll be able to try the built-in documentation.

A number of APKs and Bundles

If in case you 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 need to use ADB’s install-multiple and install-multi-package options.

If your whole 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. Try ADB’s built-in documentation for which choices can be found.

Uninstalling an App

To uninstall utilizing ADB, you may want the package deal title of the app you wish to uninstall. Try the part for Itemizing Put in Apps if you have not already.

After you have the package deal title, uninstalling is so simple as:

adb uninstall <packagename>

Observe: You usually cannot uninstall system or preinstalled apps utilizing this command. You could possibly disable them with ADB, nonetheless. Try the part Disabling & Enabling virtually any App for particulars.


There are many causes you would possibly wish to extract the APK(s) for an app. Perhaps you wish to again it up for future use, or possibly it is not accessible on-line and also you wish to switch it to a special gadget.

Extracting an app utilizing ADB is fairly easy. First, you may wish to discover the package deal 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 gadget’s Settings app to view the record of all put in apps, choose the one you need, and scroll down till you discover the package deal title or app ID.

After you have the package deal title, run the next command:

adb shell pm path <packagename>

This command will return the trail of all APKs for that package deal title.

An image showing the results of retrieving the APK paths for an installed package

You possibly can then use the next command to drag every APK to your pc:

adb pull /path/to/apk.apk


Itemizing App Parts

An app’s elements are issues like its Actions, BroadcastReceivers, Providers, and so forth. Typically it is helpful to know the names of those elements in a particular app, particularly if you wish to launch hidden Actions or ship a broadcast with particular knowledge.

Sadly, ADB does not have a really clear manner of itemizing an app’s elements. However it’s attainable. Run the next command:

adb shell dumpsys package deal <packagename>

An entire 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.
  • Verify 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 probably some additional info.

Activity Resolver Table for a dumpsys package

Alternatively, if you need a better option to see Actions, Providers, and Receivers, you need to use my Root Exercise Launcher app. It’ll present you these elements for every app, together with a bunch of different helpful options.


Launching Actions, Providers, and BroadcastReceivers

ADB can be used to launch Actions, begin Providers, and notify BroadcastReceivers. You possibly can even specify knowledge URIs and Intent extras if wanted.

To launch elements, you may want the part title of what you wish to launch. You possibly can see the right way to get that from the Itemizing App Parts 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 needn’t explicitly specify an motion. You will often solely want it if the part makes use of one apart from android.intent.motion.MAIN.

On prime of the essential syntax, here is the right way to specify extra knowledge to cross. Normally, all knowledge values needs to be enclosed in double quotes.

  • -d lets you specify an information URI.
  • -e <key> <worth> or –es <key> <worth> lets you specify a String additional.
  • –esn <key> lets you 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 cross 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 cross the values as an Integer[] additional.
  • –eial <key> <value1>,<value2>,… will cross the values as a Listing<Integer>.
  • The identical array and record arguments additionally work for longs, floats, and Strings. Simply exchange the i with the suitable letter.
  • -f lets you specify a flag.

There are much more habits choices you need to use, so try the construct in documentation for particulars.


Disabling & Enabling virtually any App

System apps in Android cannot be uninstalled, and lots of them additionally cannot be disabled via Settings. Whereas ADB will not allow you to uninstall them, it could enable you disable them.

First, ensure that to get the package deal title of the app you wish to disable. Then, strive these instructions. If one fails, strive the following possibility.

  • pm disable <package deal>
    • To re-enable, use pm allow <package deal>
  • pm disable-user –user 0 <package deal>
    • To re-enable, use pm allow <package deal>
  • pm disguise <package deal>
    • To re-enable, use pm unhide <package deal>
  • pm droop <package deal>
    • To re-enable, use pm unsuspend <package deal>
  • pm uninstall -k –user 0 <package deal>
    • To re-enable, use pm install-existing <package deal>
    • Observe: This one successfully uninstalls the appliance out of your consumer profile. Whereas the command to re-enable ought to work, there is not any assure it’ll. It’s possible you’ll have to manufacturing facility reset to revive the app.

In the event you’re utilizing a number of consumer profiles in your gadget, ensure that to interchange 0 within the instructions above with the precise consumer ID you may have.


ADB is an extremely highly effective device, and it might accomplish that far more than simply what’s above. The instructions on this article are only a helpful start line. For extra superior utilization, try instructions like cmd -l to see totally different providers you would possibly be capable to work together with or ls -l /system/bin to see the totally different command executables accessible.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button