Jump to content

  1. 0
  2. 0
  3. 0/5

Rate this Topic

* * * * *
1 votes

[REFERENCE/GUIDE] Everything about ADB!

  • Please log in to reply

OP Captainkrtek


I just shoot lasers here

Posted 07 June 2011 - 02:11 PM #1

This workshop was held in #android-learning on irc.freenode.net by XDA Member Adrynalyne. All credit to him for this guide, I simply am taking it and turning it into a guide. Here we go! :)

You can find the raw IRC log here

Good evening folks, and welcome to my ADB workshop. This is by no means a full explanation on the subject, but more of a crash course to help folks get up to speed, and get more from their devices. There may be some things you already know here, so please be patient and respect those who do not.

Reference Files

http://adrynalyne.us...install adb.pdf
http://adrynalyne.us...s/Using ADB.pdf

So, lets just start with the basics.

What is ADB?
ADB stands for the android debugging bridge and is used for testing and debugging purposes by developers.

However, we like to get more out of our devices, and its a great way to fix things.
Knowing adb can mean the difference between a paperweight and a working phone.

So, to start with, we will look at installing ADB.
Generally speaking, the Sun/Oracle JDK is required to run all SDK functions.
ADB is but one tool in the SDK arsenal.
So, we begin by downloading and installing the JDK. This can be found here:


Choose your OS, download and install. I recommend that 64 bit users use the regular x86/32 bit version as well.
Moving ahead, we download the Windows sdk from here:


Due to already installing JDK, you won't be stopped by the install process.
Now, if you notice, I installed it to:


I did this because it makes things easier when setting up path variables.
I encourage everyone to do the same, but obviously it is not required.

So, this SDK is handy, but is only good up to 2.2. We want the latest and greatest! (Well I do)

So, we navigate to:


and we run SDK Manager.exe

If you notice in your PDF file for installing adb, you will notice that you can update, and I made a choice not to include earlier sdk versions.

I won't go into full detail on that, but depending on the version of SDK you have, 8 or 9, it WILL make a difference in using adb.
By default, for version 8 adb.exe resides in C:\android-sdk-windows\tools
By default, for version 9 adb.exe resides in C:\android-sdk-windows\platform-tools
We will assume version 9 in this guide

Really, the SDK is installed and adb is usable right now, but in my humble opinion, its not enough

I like the ability to use adb in ANY directory on my machine.
To do this, we edit Windows's environment variables.
Specifically, the system path.

To do this, we click on start, or the orb (depending on OS), and right click on Computer, left clicking on properties in the menu.
If its windows XP, I believe it brings you into advanced system properties immediatly. Vista and 7 need a second step.
On the left hand side, as you notice I have highlighted in the pdf, left click advanced system settings.

Under advanced tab, we left click environment variables...
There are two boxes here.
We are concerned with system variables, however.
So we scroll down the list and highlight path and click edit.
Ignoring all the extra stuff in here, make sure you are at the end of the line, and type


The semicolon allows us to separate it

from the previous path statement.
Click ok all the way out.
We now have ADB setup globally. We can use cmd.exe (I use powershell) and no matter what directory we are in, adb is recognized.
If it is not, make certain you entered the path into system variables, and made no typos.
If you installed to a different location, you will need to adjust the path accordingly.

This concludes the section on installing the Android SDK to use ADB.

This next section will be on using ADB, so please open that pdf now.
Now, this applies to any OS, not just Windows.
Well, with the exception of the USB drivers.
I will not go too much into that, but if you take a look at the PDF, it goes through installing usb drivers for the sdk, and how to download them.
Fiarly straightforward, in that rspect.

Now, to setup our phones to use with the SDK and ADB, we must change some settings.
First, we go to menu softkey, then settings.
We scroll down to Applications and tap it.
Under Development, we will check Enable USB Debugging. Please note the SGS phones are different in this respect.
The USB cable must be unplugged before enabling or disabling this setting.
Once this is done, we are now ready to play with adb

One quick note: If you get device not found/conencted, please reboot your phone. DJ05 has a quirk in it where ADBD randomly crashes on boot.
A reboot will fix this

ADBD= ADB Daemon

Ok, continuing on.
Lets look at installing applications. This is also known as sideloading.
Unlike installing from the SD card, it does not require unknown sources to be enabled.
The command for this is

adb install packagename

This assumes that you are working from the directory where the file is located.
This will install the application to /data/app.
It will also show sometimes useful errors if install fails.
That is not something you will see from the Android GUI.
Now, a lot of us have probably deleted files with apps like Root Explorer. While this isn't really a bad thing, it leaves behind databases and data for the application removed.
This is where the 0kb applicaiton entries come from.
If you take that application entry name, you can uninstall the extra data via adb.
First we go to the adb shell which logs into the phone.

adb shell

If we end up with a $, we will want admin rights, in many cases. This is not one of them, I don't beleive.
To get admin rights, you want to type


Look at your phone if this is the first time, it may prompt you to allow access. Else you will get permission denied.
If you are not rooted, this will not work either.
Ok, now that we are logged in, we will type

pm uninstall packagename

where packagename is the name of the 0kb listing.

Now this seems like a pain in the a** and I agree.
There will be a time where Manage applications crashes when you try to uninstall it from the phone. In this case, a factory reset, or this method is the only effective way to fix the problem.
Moving on.
How many of us have removed system applications or renamed them? Did you know that you can simply disable them from the system?

adb shell
pm disable appllicationname

This will disable it, and the system will ignore it.
This can be seen as safer than deleting or renaming things, but your mileage may vary.
On the other hand, you can also re-enable these applications.

adb shell
pm enable applicationname

Please note: Not all applications will properly re-enable. I believe a factory reset or reinstall of said application will fix the issue.
Also, application names are absolutely case sensitive.

*nix based Operating Systems see the letter 'a' and 'A' as two different things.
when you log into adb shell, you are playing by android rules

Ok, a lot of us tweak and mod our phones and turning off the device to get to clockwork recovery, or battery pulls, or multiple button holds to get into Download mode are troublesome and annoying at best.
ADB can help us here.
Here, we do not need to be logged into the shell
If we want to merely reboot the phone:
adb reboot
If we want to go to recovery (works well with voodoo5)
adb reboot recovery
If we want to go to Download Mode because we need Odin, heaven forbid:
adb reboot download
Its instant. No waiting on animations or anything else.
Its also handy if Android has locked up, but yet still works in adb.
I for one hate taking my case off to battery pull.

So now we move on to pushing and pulling files.
Sometimes, I don't feel like mounting my sd card to copy a file over to my phone.
I can use this command to push a file straight to my sd card:
adb push filename /pathtodirectoryonphone
So for instance, if I have test.txt that I want to send, I would type:

adb push test.txt /sdcard/

and there it goes.

Posted Image

OP Captainkrtek


I just shoot lasers here

Posted 07 June 2011 - 02:11 PM #2

Ok moving on
Pushing files can be done to any directory, however, some are protected.
For instance, /system is going to give you a permission denied or a read only filesystem error.
To get around this, the easiest thing to do is push the file to your sdcard, then log into the shell:
adb shell
We will then mount the system as writable
mount -o rw,remount /dev/block/stl9 /system
Then we can use something like
cp /sdcard/test.txt /system/app/test.txt

cp stands for copy
and it requires the path of the file and destination path. The name of the file is optional
When you copy it, you can rename it to whatever you like.
For instance, if we wanted to backup a file
cp /sdcard/test.txt /sdcard/backuptest.txt
Now, lets assume you do not have busybox installed.
You non rooted users will not.
Then you must use a slightly more complicated command called dd
This is used like this:

dd if=/sdcard/test.txt of=/system/app/test.txt

if is for inputfile
of= output file

Not every user friendly, but probably one of the safer copy commands.

Ok, moving on to pulling files.
Lets say you want to get a file from your phone, to modify, backup, etc.
To do this, we simply use adb in this manner:
adb pull /pathtofile/filename destinationname

For instance, if I wanted to backup ADW launcher in system/app
I would do this

adb pull /system/app/ADWLaucnher.apk ADWLauncher.apk

And it will pull the file from the phone and put it in the current directory.
Like above, you can specifcy where it goes.

pushing files to the sdcard, it seems prudent to talk about changing permissions.
sdcards are typically fat32, which destroys permisisons, and Android is heavily permission based.
So if you push an application to your sd card, then try to copy it to /system/app/ bad things are going to happen, or the app may not even show up.

So in that case, we use something called chmod.
This is used in this manner
adb shell
chmod 755 /pathtoapplication/applicationname
Keep in mind
you dont want to do this while its still on your sd card.
an example
adb shell
chmod 755 /system/app/ADWLauncher.apk
755 is good for applications and script files.

Just a couple more topics to cover.
Lets go over deleting files.
This becomes especially handy for removing rogue applications.
To do this, we must be in the adb shell.

adb shell
rm /system/app/ADWLauncher.apk

You may need to remount system as writable with:

mount -o rw,remount /dev/block/stl9 /system

That applies when using chmod as well.
So what I did above was delete ADW Launcher from system/app
However, what if I wanted to delete the entire contents of a directory?
Same thing as before, except
adb shell
rm -f /data/dalvik-cache/*.*
I just cleared my dalvik-cache with that command

very quick, very effective.

If you just tried that, please reboot your phone now

Ok....this leaves us with the final topic: logcat
logcat allows us to log what the OS is doing, and possibly delve information for when things are not working
its quite simple Reading it is another.
To use logcat

adb shell

To logcat to a certain file do

adb shell
logcat > /sdcard/logcat.txt

Now we let the log settle down to a reasonable amount of data coming in and not a wall of scrolling, then start the app in question. When it gives an error, we hit ctrl-C and kill the adb shell session.

This should have captured enough data to see the error. Now, I prepared an example. A user came to me on IRC, and Google Maps was force closing. Clearing data didnt fix it, Clearing dalvik-cache, and fix permissions did not fix it. In this case, the user did not know how to use adb So I had him grab an app called alogcat from the market and email me the log. This is also a very valid method.
this file explains what the problem was, and highlights what to look for as an example.

This concludes the guide from Adrynalyne, there will be more workshops such as this one in irc.freenode.net #android-learning.
Thanks to everyone in #samsung-fascinate !

Kang'd from myself from XDA: http://forum.xda-dev...ad.php?t=879701

Posted Image




Posted 07 June 2011 - 04:10 PM #3

Beast of a thread man. Bookmarked so I can send people to this when they ask questions about adb. Not that I ever get fits from doing stuff in windows and need help myself.... :) awesome post



Supporting Member

Posted 07 June 2011 - 08:59 PM #4

+1 for sure. I read through it all and I knew a good deal of it, but learned a few things as well. Great write-up. Thanks.

Steady Hawkin

Steady Hawkin

Team Rogue

Posted 07 June 2011 - 10:26 PM #5

Great guide, thanks bruh!




  • 84 posts

Posted 07 June 2011 - 11:18 PM #6

Quick tip: mount system using the following commands it is easier ( device irrespective as far as I know.) :

Mount read/write

mount -o remount,rw /dev/null system

Mount read only

mount -o  remount,ro /dev/null system





Posted 10 June 2011 - 07:28 PM #7

One question that I have, I can not seem to get the Google drivers to load for my droidX. I installed the SDK and the Google drives but it keeps telling me that it can not install. The rest of this write up is great.



Android Apprentice

  • 34 posts

Posted 10 June 2011 - 07:31 PM #8

Have you downloaded the motorola drivers?

Sent from my HTC Glacier using Tapatalk




Posted 10 June 2011 - 07:41 PM #9

NO I did not as I thought that is what the google ones are for I will do so.




Posted 11 June 2011 - 05:27 AM #10

Ran into a problem, trying to load the drivers and i installed the motorola ones it won't install when I plug in the phone.
Gtalk - RayToombs
<a href="http://twitter.com/sbmooTyaR" class="twitter-follow-button" data-show-count="false">Follow @sbmooTyaR</a>
<script src="http://platform.twitter.com/widgets.js" type="text/javascript"></script>

DroidX - Stock TBH .596 with AOSP Google Liberty