[Android General] Qui Peccavit:
Install and configure Android Debug Bridge (ADB)

ANDROID DEBUG BRIDGE (ADB)

Setup & Configuration​

Google's Android Software Development Kit and Debug Bridge (ADB), better known as Android Studio, are not only useful for programmers and software developers. The command line tools that are included can come in very handy to copy files from and to the phone, flash custom binaries, uninstall bloatware or even boot the phone into special modi when the buttons do not respond or are too complicated to push quickly enough in the right order.

As a prerequisite for the ADB command line (power shell) tools, download and install Java. For basic purposes, the runtime environment will suffice, but for application development or reverse engineering, the Java Development Kit is needed.

Now set up Android Studio on the computer, which includes Android SDK's command line tools as well as the ADB platform tools and keeps them updated. After having finished the installation, do not forget to add the locations of the respective directories, for example ...

C:\Users\[USERNAME]\AppData\Local\Android\Sdk\tools

C:\Users\[USERNAME]\AppData\Local\Android\Sdk\platform-tools

... to Windows' System Environment Variable.

To do so, press [Windows]+[R], enter Control and go to System - Advanced System Settings. At the bottom of the 'Advanced' menu tab, click on 'Environment Variables' and under 'System Variables' (or just for your user name), click on 'Path' to edit it. Put a semicolon at the end of the existing entries and then add the paths to the two directories above, separated by a semicolon, which should for instance look like ...

C:\Users\[USERNAME]\AppData\Local\Android\Sdk\tools;C:\Users\[USERNAME]\AppData\Local\Android\Sdk\platform-tools

Reboot the computer in order for the changes to take effect.

From now on, by holding [Shift] while right-clicking an empty area in any directory to «Open a Command Window here», the Android tools are available from the Command Line/Power Shell anywhere on the system as if they were internal Windows commands.

It is possible that unlike adb, fastboot requires root privileges to execute correctly. Add 'sudo' before the command or open CMD in privileged mode.

Elevate the privileges for ADB Command Tools

http://forums.AndroidCentral.com/ask-question/872852-am-i-able-grant-root-app-using-adb.html

http://www.AskVG.com/hidden-secret-...-run-box-using-task-managers-new-task-option/

http://github.com/TilesOrganization/support/wiki/How-to-use-ADB-to-grant-permissions

http://Greenify.uservoice.com/knowl...o-grant-permissions-required-by-some-features

http://www.Guru99.com/adb-connect.html

http://www.HowToGeek.com/194041/how-to-open-the-command-prompt-as-administrator-in-windows-8.1/

http://StackOverflow.com/questions/27274339/how-to-use-su-command-over-adb-shell, http://StackOverflow.com/questions/38064396/elevated-priviledges-on-android-app, http://StackOverflow.com/questions/25477424/adb-shell-su-works-but-adb-root-does-not#

ADB Commands

http://ADBcommand.com

http://www.GizmoAdvices.com/fastboot-adb-commands/

http://KreateTechnologies.com/terminal-commands-android-debug-bridge/

http://Android.Tutorials.how/adb-commands/

ADB Usage

http://www.linkedin.com/pulse/how-hack-android-devices-2-easy-steps-using-adb-albert-lim-1

http://Medium.com/@xabaras/android-grant-all-runtime-permission-whith-adb-18082b32ecb1

http://www.PCWelt.de/ratgeber/Andro...ckte-Daten-auf-dem-Android-Handy-4226863.html => http://ReviewLand.website/2018/08/31/android-debug-bridge-the-back-door-to-android/

http://pspdfKit.com/blog/2019/android-debug-bridge-tips-and-tricks/

http://StackOverflow.com/questions/23081263/adb-android-device-unauthorized

FWUL, http://xdaforums.com/android/software-hacking/live-iso-adb-fastboot-driver-issues-t3526755

It is recommendable to run ADB commands with elevated privileges, i.e. opening the command prompt (power shell) as administrator. In order to do so, press [Windows]+[X] or right-click on the [Windows] button in the task bar and choose «Command Prompt (Admin)».

The first thing to do after connecting the phone to the computer consists in checking whether the computer recognized it correctly, by entering the following command:

> ADB Devices

example response: 37dca318f1s9adb device

In case the list of devices turns up empty or as 'unauthorized', be aware that sometimes, even connecting the phone to a different USB port on the same PC can cause trouble. Also if being tethered, it may become necessary to disconnect from the Wi-Fi network. There are several approaches to resolve those problems , but this is the solution that should work most of the time:

a.) Shut down the ADB Server on the PC

> ADB kill-Server

b.) Disconnect the phone from the computer

Unplug the USB cable between phone and PC.

c.) Revoke previous Debugging Authorisations

On the phone, in Settings | Developer Options, switch off 'USB Debugging' and 'Revoke USB debugging Authorisations'. Now turn 'USB Debugging' back on again.

d.) Restart the ADB Server on the PC

> ADB start-Server

e.) Reestablish the connection between phone and computer

Reconnect the USB cable between the two devices.

f.) Authorize the computer on the phone

Confirm the dialogue to authorise connections to the phone from that PC. If no message pops up, remove \data\misc\adb\adb_key and adbkey.pub in the ADB installation directory, reboot your phone and try connecting again. The message should come up.

g.) See if ADB recognizes the phone now

Some phones require to be rebooted for this to work, but see first if it does without triggering the RMM lock once again by doing so.

For most devices, the value returned by Build.SERIAL (in android.os.Build) returns the same as that returned by ADB Devices. If no serial number is displayed, see if this helps. ADB and FASTBOOT do not display the same serial number,

adb shell getprop | grep ro.boot.serialno <= the SSN (or UDID?) ser. number

adb shell idme print | grep "^serial"

adb shell getprop ro.serialno

adb get-serialno <= IP instead of SN if connected over TCP rather than over USB

For more commands and usage tips, check the links above and the documentation that you can choose to install from within Android Studio after having completed the setup routine.