Android has a clean tool for developers called Android Debug Bridge, or ADB for short. It is used in Android Studio and by Android developers to install and test apps on Android smartphones and AMOLED Android devices.
But ADB can do a lot, and most of it is not just for developers. Even if you are not a developer and you are reading this article, there is a good chance that you may have used ADB once or twice to install an app or edit permissions. Be But not all of this can be used for ADB. Keep reading some tips and tricks for using ADB that you may not be aware of.
Shell access.
If you have used ADB before, you may get in the habit of running commands in a single line. But you can also use ADB to open the terminal shell on your device and run commands directly. And it’s easy!
In your terminal or command prompt window:
adb shell
Then you will be welcomed with one. $
Symbol where you can run commands directly on your device.
Listing of apps installed through ADB.
To see the apps installed on your device, you can use the following command:
adb shell pm list packages
It will return a list of package names of installed apps, each presented on its own line. package:
.
authorities
There are also specific options that you can use to retrieve more specific lists.
- -ف The package name will include a base APK route for each app.
- -ا Ensure that all known non-APEX packages are returned.
- -D The command will only return disabled packages.
- -ای The command will only return active packages.
- -س The command will only cause the system package to be returned.
- -3. The command will only return third party packages.
- -I Each package will include the name of the installer package.
- -U The package will include UID for each package.
- -و Installed packages will be included.
- Show version code. Version code will be included for each package.
- – Just above Only APEX will return the package.
۔ Only show the package with the given UID.- User
۔ Only show packages related to the given user ID.
Installing and uninstalling apps via ADB.
This is a relatively common use of ADB, but it is worth mentioning anyway. Alternatively, you can use ADB to install and uninstall Android apps on your Android device.
Installing an APK
If you have an APK on your computer, you can install it on your device with the following.
adb install -r someapk.apk
Remember to change. someapk.apk
With the full path of the APK you want to install.
authorities
There are many options for installing APKs via ADB.
- Of -ر The option allows ADB to be installed on existing apps (ie updates). Android Pie and later, you do not need to specify this option.
- Of -R Options, Android Pie and later, if the app is already installed, the installation will fail.
- Of -I The option lets you specify the name of the installer package. If Android wants to know what APK installs, this is what comes back.
- Of -T The option allows with an APK. android: testOnly = “true” To be installed in its manifesto.
- Of -D The option allows the specific APK to be downgraded to a pre-installed app. This only works when both versions of the app are debugable.
- Of -G The Android Marshmallow option and later the automatically installed app gives all the runtime permissions.
This is not one of them. If you want a complete list, you can check the built-in documentation.
Multiple APKs and bundles.
If you have a bunch of APKs that you want to install at the same time, either from multiple apps, or because you are installing the app bundle, you can use ADB install-multiple
And install-multi-package
Features.
Use if all your APKs are for one app. install-multiple
:
adb install-multiple apk1.apk apk2.apk ...
Otherwise, use. install-multi-package
:
adb install-multi-package app1.apk app2.apk ...
The powers of these orders are the same. install
, But with some limitations. View ADB’s built-in documentation for which options are available.
Uninstalling the app.
To uninstall them using ADB, you’ll need the package name of the app you want to install. Check the section for Listing of installed apps. If you haven’t already.
Once you have the package name, installing them is as easy as:
adb uninstall <packagename>
Note: You cannot usually uninstall a system or installed apps using this command. However, you can disable them via ADB. Check the section. Deactivating and activating almost any app. For details.
Extracting APKs with ADB.
There are many reasons why you might want to download an APK (s) for an app. Maybe you want to back it up for future use, or maybe it’s no longer available online and you want to transfer it to a different device.
Extracting an app using ADB is very easy. First, you’ll want to find the package name of the app you want to remove. There are several ways to do this, but usually the easiest is to use your device’s settings app to see a list of your installed apps, choose the one you like, and scroll down until you’re done. Package name or app ID not found.
Once you have the package name, run the following command:
adb shell pm path <packagename>
This command will redirect all APKs to the name of this package.
You can then use the following command to drag each APK to your computer.
adb pull /path/to/apk.apk
List of app components.
The components of an app are things like its activities, broadcast receivers, services, and so on. Sometimes it is useful to know the names of these components in a particular app, especially if you want to initiate hidden activities or send a broadcast with specific data.
Unfortunately, ADB does not have a very clear method of listing app components. But it is possible. Run the following command:
adb shell dumpsys package <packagename>
A whole bunch of text will be returned.
- Scroll until you find it. Activity Solving Table. Title to view activities.
- Look down Receiver resolver table. For broadcast receivers
- Check Service reserve table. For services.
- and so on.
Each component will show the process required to start it, the component name and possibly some additional information.
Alternatively, you can use the My Root Activity Launcher app if you want an easy way to view activities, services and recipients. It will show you the components for each app, along with other simple features.
Launch activities, services and broadcast receivers.
ADB can also be used to initiate activities, launch services, and notify broadcast receivers. You can even define data URIs and Intent Extras if needed.
To launch the component, you will need the name of the component you want to launch. You can see how to get it. List of app components. Section
The command syntax for starting an activity is something like this:
am start -a <action> -n <component>
The command syntax for starting the service is something like this:
am startservice -a <action> -n <component>
The command syntax for notifying the broadcast receiver is something like this:
am broadcast -a <action> -n <component>
In most cases, for activities and services, you do not need to clearly define the action. You will usually only need it if the ingredient is used by someone else. android.intent.action.MAIN.
On top of the basic syntax, here’s how to explain more data to pass. Generally, all data values must be enclosed in double quotes.
- -D Allows you to specify the data URI.
- -e
۔ ۔ Allows you to specify a umbilical string extra. ۔ - -no <کلی> <قیمت>۔ Used to describe extra numbers.
۔ - –Ef
۔ - –Eu
۔ - –Ecn
۔ - iaeia
, , - ialeial
, , Will pass - The same row and list arguments also work for lungs, floats and strings. Just change. I With appropriate letter
- -ف Allows you to specify the flag.
There are even more behavior options that you can use, so see the build in documentation for details.
Deactivating and activating almost any app.
System apps cannot be installed on Android, and many of them cannot be disabled through settings. Although ADB will not allow you to uninstall them, it can help you disable them.
First, be sure to name the package of the app you want to disable. Then, try these commands. If one fails, try the next option.
- pm inactive
- To reactivate, use. pm
Enable
- To reactivate, use. pm
- pm inactive user 0 user 0
۔ - To reactivate, use. pm
Enable
- To reactivate, use. pm
- Hide PM
- To reactivate, use. pm unhide
- To reactivate, use. pm unhide
- pm suspended
- To reactivate, use. PM uninstalled
- To reactivate, use. PM uninstalled
- pm uninstall -k –user 0
- To reactivate, use. pm install current
- Note: This effectively installs the application from your user profile. While the command to reactivate. Should Work, there is no guarantee. You may need to perform a factory reset to restore the app.
- To reactivate, use. pm install current
If you’re using multiple user profiles on your device, be sure to change. 0 In the above command with the actual user ID you have.
ADB is an incredibly powerful tool, and it can do more than the above. The commands in this article are just a useful starting point. For more advanced use, check the command. cmd -l To see the various services with which you can chat or ls -l / system / bin. To see the execution of various commands available.