[ HOW TO ] ADB AND WHY I LOVE ADB commands <3

Discussion in 'Android Hacks and Help' started by Flomaster, Mar 17, 2010.

DroidForums.net is the premier Android Forum - Registered Users do not see these ads. Please Register - It's Free!
  1. Flomaster
    Offline

    Flomaster Premium Member Premium Member

    Joined:
    Jan 14, 2010
    Messages:
    1,073
    Likes Received:
    0
    Trophy Points:
    36
    Location:
    East Texas
    Ratings:
    +0
    [ how to ] adb and why you will love it <3

    I haven't seen a simple ADB COMMANDS tutorial here so here it goes


    Motorola Drivers: if you don't have it installed already get it here:
    USB and PC Charging Drivers - Motorola USA


    First you need the Google's Android SDK download it here:
    Android SDK | Android Developers
    put the contents of the zipped file in C:/android/
    it should look like this:
    [​IMG]
    Now, set your PATH environment variable by right click on My Computer, and select Properties. Under the Advanced tab, hit the Environment Variables button, and in the dialog that comes up, double-click on Path under System Variables. at the end of the line add a semicolon then the full path to the tools directory to the path, in this case, it is: C:\android\tools
    Then click OK , OK , OK.

    I am running Win7 so XP and vista might look a bit different:
    [​IMG]





    Make sure you have USBDebugging checked on your phone:
    Menu>settings>Application Settings>Development>USB DEBUGGING


    The long drawn out way to Mount your system
    To Mount as Read-Write:
    JUST FOUND OUT ABOUT THIS AND IT DOESN'T REQUIRE A SCRIPT
    Code:
    adb remount
    OR THE LONG WAY
    Code:
     mount -o remount,rw -t yaffs2 /dev/block/mtdblock4 /system
    To Mount as Read-Only
    THE LONG WAY
    Code:
    mount -o ro,remount -t yaffs2 /dev/block/mtdblock4   /system
    IT GOT OLD QUICK

    I found out about scripts and found a couple to make my life easier (down load the attached zip and push to the same directory you have busybox installed /system/xbin OR /system/bin/)
    **use the mount command above in order to do this.**


    sysrw = mounts the system as read-write
    and
    sysro= mounts the system as read-only

    then came root explorer great it mounts for you and makes copying files easy,
    but then I ended up connecting to the computer,
    clicking mount USB
    copy files to sdcard ,
    unmount USB,
    copy file from the sdcard to the Droid.
    blah time consuming and since my usb was already connected why not use the ADB....

    well with the ability to ADB PULL / ADB PUSH I can quickly and easily move files from the droid to the pc or sdcard with ease.

    Commands:

    change to android tools directory: its a good idea to keep it simply mine is located in c:/androind/tools
    Code:
    cd c:android/tools/
    now you can run your ADB commands

    Mount the system as Read-Write:
    this will mount your system as Read-Write using the script you placed in your /system/xbin/ directory. you can then push and pull files from your DROID
    Code:
    adb shell
    su
    sysrw


    adb pull:
    to be done from the directory your tools are in
    example c:/android/tools/>adb pull

    Code:
    adb pull /system/framework-res.apk framework-res.apk
    this pulled the framework-res.apk from /system/framework/ to your adk tools directory you can make changes to it and push it back


    adb push:
    to be done from the directory your tools are in
    example c:/android/tools/>adb push
    **these are case sensitive so Launcher2.apk does not equal launcher2.apk
    Gmail.apk does not = gmail.apk Phone.apk does not = phone.apk**
    get my drift?
    Disclaimer: when pushing framework-res.apk while not in recovery mode it MIGHT cause boot loops. it doesn't for me, but had for others so if you push framework-res.apk and get boot loops, boot into recovery and push it again.
    Code:
    adb push framework-res.apk   /system/framework/framework-res.apk
    this pushed back the framework-res.apk

    Mount the system as Read-Only
    :
    this will mount your system as Read only and sync using the scripts you placed in /system/bin/ directory
    Code:
    adb shell
    su
    sysro
    Rebooting:
    Rebooting is easy

    to be done from adb shell
    Code:
    adb shell
    su
    reboot
    OR
    Code:
    adb shell
    su
    reboot recovery
    OR
    to be done in tools directory

    c:/android/tools/>

    Code:
    adb reboot
    adb reboot recovery



    Screen Capture:
    to be done from Tools directory
    example
    Code:
    c:/android/tools/>ddms.bat
    to quickly open the screen capture tool type ddms.bat
    click on the image of a phone on the left and click the Device menu then screen cap or press Ctrl+S

    EXAMPLES OF USING ADB TO:

    Boot Animations: download your boot animation and place in tools folder it can be called what ever you want because the file will be be changed when we push it.
    you mounted as read-write exited out of abd shell into your tools folder and pushed your oddly named boot animation to /data/local/ and renamed to bootanimation.zip


    Pull a file and push it back:
    I will pull my launcher2.apk change the app drawer handle and push it back with my new app drawer images :)
    Code:
    adb shell
    su
    sysrw
    exit
    exit
    adb pull /system/app/Launcher2.apk Launcher2.apk
    we pulled launcher2.apk from /system/app/ and name it Launcher2.apk and put it in the tools folder on the computer. make your changes to the apk so you can push it back
    Code:
    adb push Launcher2.apk /system/app/Launcher2.apk
    adb shell
    su
    sysro
    reboot
    I pushed the new launcher2.apk back to /system/app/ mounted the system as read only and sync'd and rebooted.

    Changing Directory from ADB SHELL:
    not you need to have a forward slash in front of the directory
    Code:
    adb shell
    su
    cd /sdcard 
    cd /system/app/
    cd /data/app/
    
    Now maybe you want to see what files are residing in that directory to do that we we the ls command:
    Code:
    adb shell
    su
    cd /system/xbin/
    ls
    [COLOR=Red][B]This will return a list of all the files in  the "xbin" directory[/B][/COLOR]
    
    Removing stock Apps: email, corp cal,amazon.mp3
    these reside inside or /system/app/

    Code:
    su
    sysrw
    cd /system/app/
    ls
    [B][COLOR=Red]this now shows you what apps are inside of there note you need to type the name exactly as displayed as it is case sensitive [/COLOR][/B]
    rm com.Email.apk
    rm com.CorpCal.apk
    sync
    reboot
    Removing left over data from the APKS:
    menu>settings>applications>manage applications
    these will usually start with "com" just type the file name as it is on the droid I did with with my droid on so I could see the file names.
    Code:
    su
    sysrw
    pm uninstall com.motorola.calendar
    pm uninstall com.android.email
    pm uninstall com.android.mms
    [B][COLOR=Red]*must be done after removing the APK, you will get "Sucess" message after it removed it*[/COLOR][/B]
    I can update the OP if I missed some stuff, but im at work and want to get home to my family and enjoy some pints of beer ;)


    -=Jason=-
    Last edited: Mar 31, 2010
  2. adrynalyne
    Offline

    adrynalyne Premium Member Premium Member Developer

    Joined:
    Dec 21, 2009
    Messages:
    2,896
    Likes Received:
    4
    Trophy Points:
    103
    Ratings:
    +4
    Nice write up. Very nice. :)
  3. thebowers
    Offline

    thebowers Premium Member Theme Developer Premium Member

    Joined:
    Nov 24, 2009
    Messages:
    2,548
    Likes Received:
    1
    Trophy Points:
    101
    Location:
    Iowa
    Ratings:
    +1
    May want to add for pushing framework-res.apk that you would want to do this through recovery. As it tends to cause a boot loop if done with the system running.
  4. loop4zil
    Offline

    loop4zil Member

    Joined:
    Dec 29, 2009
    Messages:
    743
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Atlanta
    Ratings:
    +0
    Thank you for this
  5. Flomaster
    Offline

    Flomaster Premium Member Premium Member

    Joined:
    Jan 14, 2010
    Messages:
    1,073
    Likes Received:
    0
    Trophy Points:
    36
    Location:
    East Texas
    Ratings:
    +0
    I will put a disclaimer in there:

    odd I haven't had any bootloops at all when I was changing my "pull down Text" I pulled my framework-res.apk changed the eri.xml file pushed it back sycned and rebooted. when metamorph themes the framework-res.apk it isn't in recovery.


    -=Jason=-
  6. adrynalyne
    Offline

    adrynalyne Premium Member Premium Member Developer

    Joined:
    Dec 21, 2009
    Messages:
    2,896
    Likes Received:
    4
    Trophy Points:
    103
    Ratings:
    +4
    Something to add:

    Code:
    adb reboot
    adb reboot recovery
    
    You dont specifically have to be in the shell to do these. I have no idea why I mentioned that. I guess its the commands I use the most.
    Last edited: Mar 17, 2010
  7. thebowers
    Offline

    thebowers Premium Member Theme Developer Premium Member

    Joined:
    Nov 24, 2009
    Messages:
    2,548
    Likes Received:
    1
    Trophy Points:
    101
    Location:
    Iowa
    Ratings:
    +1
    With MM you aren't pushing and replacing the whole framework file. It may not be an issue with ADB, but if you try it in terminal it will do an instant reboot and never load. Kind of like what some people are seeing when pushing MM themes on ESE53 builds.
  8. Flomaster
    Offline

    Flomaster Premium Member Premium Member

    Joined:
    Jan 14, 2010
    Messages:
    1,073
    Likes Received:
    0
    Trophy Points:
    36
    Location:
    East Texas
    Ratings:
    +0
    ahh I see what you mean, I edited my post with a warning about a possible boot loop.

    -=Jason=-
  9. Topsy
    Offline

    Topsy Member

    Joined:
    Dec 28, 2009
    Messages:
    677
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Rio Rancho, New Mexico
    Ratings:
    +0
    I've never had framework-res.apk pushing cause a bootloop, but it will force a reboot if you push it onto a running phone for sure.
  10. SoDroid
    Offline

    SoDroid Member

    Joined:
    Jan 18, 2010
    Messages:
    219
    Likes Received:
    0
    Trophy Points:
    16
    Ratings:
    +0
    Please don't burn me for this :)
    I have done many things to my phone but I have found ways of doing them that do not involve ADB Shell. I prefer to not deal with lines of code. But I have found that for somethings, I need ADB. (Here comes the burn part) Where can I download ADB Shell? I searched the forums and everyone just talks about how to use it, not where they got it.

    I assume its apart of the SDK but I do not know.

    -I don't think I've ever felt so nooblike.
  11. Droidfish
    Offline

    Droidfish Member

    Joined:
    Feb 2, 2010
    Messages:
    860
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Deep South of NM
    Ratings:
    +0
    No burns. <ADB Shell> is a command within adb that allows you to control your phone from your pc. No download needed, all you need is the SDK. ADB is run through your windows command prompt.
  12. starscream
    Offline

    starscream Decepticon Premium Member

    Joined:
    Mar 3, 2010
    Messages:
    317
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Idaho
    Ratings:
    +0
    nice post!!

    this should help a lot of people out
  13. SoDroid
    Offline

    SoDroid Member

    Joined:
    Jan 18, 2010
    Messages:
    219
    Likes Received:
    0
    Trophy Points:
    16
    Ratings:
    +0
    Thank you for the helpful response Droidfish! I was looking on the Android Developers site, and it said the required OS software for Windows is either XP or Vista. Does anyone know if this will work with Windows 7?
  14. Droidfish
    Offline

    Droidfish Member

    Joined:
    Feb 2, 2010
    Messages:
    860
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Deep South of NM
    Ratings:
    +0
    No problem. I don't have windows 7 but if I remember correctly it will work with the exception that you need administrator privileges.
  15. Flomaster
    Offline

    Flomaster Premium Member Premium Member

    Joined:
    Jan 14, 2010
    Messages:
    1,073
    Likes Received:
    0
    Trophy Points:
    36
    Location:
    East Texas
    Ratings:
    +0
    I am running Win7 Pro x64 so yes it works.

    just download and install the SDK and make sure you have the current motorola driver.do DO NOT need to load up those virtual files to use the "TOOLS" within the SDK. nor do you need Java to do ABD.

    I shall edit my first post to make sure people have SDK installed

    -=Jason=-
Search tags for this page
adb command
,

adb commands

,

adb pull

,
adb pull directory
,

adb reboot

,

adb shell commands

,
adb su
,

adb sync example

,
how to adb pull
,

how to use adb