19
Guide What is ADB?

?

Did this guide help?

  1. Yes

    20 vote(s)
    52.6%
  2. No

    2 vote(s)
    5.3%
  3. A little

    2 vote(s)
    5.3%
  4. Potato

    14 vote(s)
    36.8%
  1. AlphaX2025
    Honeycomb Feb 18, 2015

    AlphaX2025 , Feb 18, 2015 :
    Many users are not familiar with Android SDK or ADB commands, this thread is created with an intention to help them!

    [​IMG]

    Look at any tutorial for rooting an Android device, and one set of initials is sure to come up: ADB. Veterans to Google’s mobile platform will let it roll off their tongues as if it’s everyday language, but those new to Android hacking can get a little tripped up. What the $%#@ is ADB? Let’s take a look.

    Introduction:
    Android Debug Bridge (adb) is a versatile command line tool that lets you communicate with an emulator instance or connected Android-powered device.

    Pretty difficult to understand, eh?

    ADB is a tool that allows you to talk with your device and accomplish a host of different tasks from your computer, such as transferring data, recording the screen's output to a video file, and running powerful shell commands.In simple words. it’s a “bridge” for developers to work out bugs in their Android applications. This is done by connecting a device that runs the software through a PC, and feeding it terminal commands. ADB lets you modify your device (or device’s software) via a PC command line.

    If command line syntax confuses or intimidates you, have no fear. For most average users, the only time you’ll need to use ADB is when you have step-by-step instructions in front of you.

    Installing Android SDK i.e. ADB:
    Aside from ADB, the other set of initials that you see with Android hacking is SDK. This stands for Software Development Kit. So yes, in order to root most devices, you’ll need to download the entire platform that developers use to create apps.

    To get started, pick up the version of Android SDK for your platform:

    Windows
    Mac OS X
    Linux


    Once downloading, extract the file to an easy-to-remember place on your PC. On Windows, we’d recommend installing it in your root (c:) drive, in order to make it easier to navigate there via command line.

    [​IMG]
    Now you’ll want to open the folder that you extracted the SDK into, and launch the SDK Manager (on OS X, you do this by executing the program ‘Android,’ which is located in the ‘Tools’ folder in the SDK).

    After launching SDK Manager, you’ll see a list of optional packages to download and install. Find the one that says “Android SDK Platform Tools” (you may need to expand the “Tools” entry to find it). Once you locate it, check its box to indicate that you want to install it (choose “accept”). Unless you want to develop apps, it’s safe to uncheck everything else (choose “reject”).

    After choosing “Install,” Platform Tools will be automatically downloaded, and you’ll be (almost) ready to use ADB.

    Using ADB:
    Though I am not hear to teach you Linux programming, it will help you to know a few basic methods to using ADB.

    First, you need to enable developer options on your device. This is done by going to Settings -> About phone and tapping the Build number 7 times.
    You will now have Developer options available in the Settings menu. Enter Developer options and click the check box that says USB Debugging. A popup box will appear that asks you to confirm your choice.
    Next, attach your device to your computer via a USB cable. At this point you should get a popup that asks you if you would like to allow USB debugging from this computer. It will display your computer's RSA key fingerprint. Check the "Always allow from this computer" box and tap OK.

    The most important thing to know is simply how to get to your ADB folder via the command line.
    • Go to the directory where SDK is located
    • Open "platform-tools" folder
    • Hold "Shift" and "Right Click"
    • Select "Open command window here"
    • Done
    Basic ADB Commands:
    Now that ADB is installed and working properly, let's see what it can do.

    Pushing Files
    adb push <path-to-file> <device-destination>
    This command pushes a file from your computer to your device.
    Use-case: Pushing a ROM on to your phone when copying it over normally is not possible, for example, if your current ROM won't boot and you are stuck in recovery.
    Example: adb push sample.zip /sdcard/
    This would send a file called sample.zip (in this case the file is in the current folder you are in when you issue the command) to the root of the SD card on your Android device.

    Pulling Files
    adb pull <path-to-file-on-device> <destination-path-on-computer>
    This command pulls a file from your device to your computer.
    Use-case: Pulling important files off of your device before performing a full wipe.
    Example: adb pull /sdcard/sample.zip C:\
    This command copies a file called sample.zip from the root of the SD card to the root of my C drive.

    Installing Apps
    adb install -r <path-to-APK-file>
    This command installs an APK file (an app) from your computer to your phone. The optional -r flag tells ADB to reinstall the app and keep existing data if it is already on your device. Using this method, the app will be installed very quickly, without any prompts displaying on the device itself.
    Use-case: Quickly installing apps that you have backed up on your computer.
    Example: adb install -r C:\AppBackups\NerdRage.apk
    This command installs an app located in a specific folder on my computer to my device, silently. If you watch the phone, nothing seems to happen, there are no popups or notifications displayed, the app just appears in your app drawer.

    Logging

    adb logcat
    This command displays a real-time stream of your device's log on your computer.
    However, raw logcat output is not very helpful as it is very difficult to sort through, and continues to stream until you stop it (Ctrl+C). Thankfully, logcat output can easily be filtered in a number of useful ways, though a discussion of that is outside the scope of this tutorial.
    Use-case: You are troubleshooting an app you built or you are an awesome end user assisting a developer to troubleshoot their app.

    Advanced Techniques
    Here are a couple of advanced ADB commands that you can use to do some really cool things.

    Enter Your Device's Shell

    adb shell <command>
    This command executes a single shell command.

    adb shell
    This command opens a remote shell on your computer, allowing you to enter multiple commands.
    Interacting with your device's shell is identical to navigating the terminal in Linux in terms of command syntax, however, your device has a significantly smaller set of commands available to you. If you would like more command line tools at your disposal, try installing Busybox.
    The shell gives you access to a very wide variety of functions, however, most shell commands of any consequence will require your phone to be rooted to run. In addition, playing around in the shell with root access can be disastrous if you don't know what you are doing, so exercise caution.
    Use-case: Too many to list.
    Example: adb shell pm list packages -f
    This command displays all the packages (apps) currently installed on your device.
    Example: adb shell top
    This command runs a binary called "top" that displays running processes and their CPU and memory usage.

    These are just a couple of very basic examples—when it comes to the shell, the sky's the limit and people are constantly coming up with new uses for this functionality.

    Recording Your Screen's Output to a Video File
    This feature is new to Android 4.4 KitKat. It allows users to record screen activity to an MPEG-4 file, which you can then download.
    adb shell screenrecord <path-on-device-to-save-video-to>
    Running this command will start a screen recording that is saved locally on your device. The recording will continue until you stop it by hitting Ctrl+C, or automatically after three minutes of recording.
    Use-case: Creating a video presentation that involves using your Android device.
    Example: adb shell screenrecord /sdcard/Demo.mp4
    The video file that is created displays smoothly, and the actual act of recording the screen does not seem to adversely affect device performance.

    Conclusion
    Now that you know what ADB is, and what you can do with it, go out and conquer the command line with confidence.

    Disclamer : This information was sources from various websites.
     

    #1
  2. Hanson Lee
    Marshmallow Feb 18, 2015


    #2
    esaurabh and Ceasedd like this.
  3. gusuraman
    Community Veteran Feb 18, 2015


    #3
  4. esaurabh
    Ice Cream Sandwich Feb 18, 2015


    #4
    Ceasedd likes this.
  5. sh3llshock
    KitKat Feb 18, 2015


    #5
  6. sidlittlefield
    KitKat Feb 18, 2015


    #6
    Ceasedd and takeabyte like this.
  7. gmo8492
    Lollipop Feb 18, 2015


    #7
    Ceasedd likes this.
  8. DaxNagtegaal
    Marshmallow Feb 18, 2015


    #8
    Himanshu Sable likes this.
  9. ikbenben
    Gingerbread Feb 18, 2015


    #9
  10. B4kken
    Lollipop Feb 18, 2015

    B4kken , Feb 18, 2015 :
    This is something I've been curious about learning but haven't found a good guide yet.. Thanks! I'll read through this after work :)
     

    #10
  11. rrluvs
    Ice Cream Sandwich Feb 18, 2015


    #11
  12. wea3el
    Honeycomb Feb 18, 2015


    #12
    Ceasedd likes this.
  13. mreddy
    Gingerbread Feb 18, 2015


    #13
    Ceasedd likes this.
  14. Sandesire
    Jelly Bean Feb 18, 2015


    #14
  15. Funk Wizard
    Lollipop Moderator Feb 18, 2015


    #15
    Dhrumin226 likes this.
  16. SRIDHARSWC
    Gingerbread Feb 18, 2015


    #16
    Ceasedd likes this.
  17. awkward_potato
    Lollipop Feb 18, 2015


    #17
    Ceasedd likes this.
  18. thiazhangwei
    Honeycomb Feb 18, 2015

    thiazhangwei , Feb 18, 2015 :
    Thanks for the very informative guide! (Coming from someone who spent half an hour doing "adb shell wm density" because I had no idea what I was doing and what to install)
     

    #18
    Ceasedd likes this.
  19. AlphaX2025
    Honeycomb Feb 19, 2015


    #19
    Ceasedd likes this.
  20. takeabyte
    Ice Cream Sandwich Feb 19, 2015


    #20
    Ceasedd likes this.