• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Root [GUIDE] The ADB Era

savoxis

Android Expert
So as you know, in order to get 2.2.1 rooted and with a custom recovery, it is necessary to follow the steps Trident layed out http://androidforums.com/ally-all-things-root/263285-guide-froyo-2-2-1-root-users.html and in my opinion this is the greatest thing to happen to the Ally community to date.

Since in Trident's guide you need to setup both ADB and FASTBOOT to work with your ally; this allows for the vast majority of the community to have working development tools handy. This should usher in a new Era, an Era where problems are easily solved, and everyone has at least a little terminal experience.

So, since most of you running 2.2.1 will have the dev tools set up here is some info on ADB:

What is ADB
"ADB stands for Android Debug Bridge. It comes as a part of the standard Android SDK. Basically, it provides a terminal-based interface for interacting with your phone’s file system. Since Android platform is based on Linux, command-line is the only way to obtain and manipulate root access.

While these things can be done directly on the device itself using some terminal emulator, it will be rather difficult to execute complex commands on such a small screen. ADB provides the bridge between your machine and your computer."
-Google

Starting ADB
As per Trident's guide your development tools should be located at C:\android-sdk\platform-tools if you extraced your SDK into another directory change as needed.

  1. Plug phone into USB and ensure "USB Debugging" is on
  2. Open up a command prompt by either holding windows key and tapping R and typing in cmd, or start menu run then type in cmd, or start menu search cmd and select.
  3. type cd C:\android-sdk\platform-tools
  4. type adb start-server

Using the Shell
Now that you have the ADB server started up and have a command prompt in the proper directory you can initiate an ADB shell to do this you must simply type adb shell and you will be presented with a $ prompt.
This is a UNROOTED terminal,
$=Unrooted
#=Rooted
Since most terminal commands you will want to issue require root a good place to start is by requesting root you do this by typing su. When you press enter your phone will pop up a little toast asking if you want to allow root access. If your phone was locked when you typed su you will need to issue the command again as you will not be presented with the request. You only have to allow once, all future requests from ADB will be automatically accepted.

So your in a rooted shell, congrats. The first thing most people want to do is remove bloatware strored in /system/app to do this first you must remount the /system partition read-write
Code:
mount -o remount,rw -t yaffs2 /dev/block/mtdblock4 /system
If it was successful it will simply go to the next line. Next we should navigate to /system/app
Code:
cd /system/app
To see what is in the directory issue the ls command. On stock 2.2.1
you will notice there are 2 files for every app, one is the apk the other the odex.
To remove an app you must remove both, an easy way to do this is
Code:
rm SNS*
That command will remove SNS (socialite) the * makes it remove everything that
matches the first segment, so it will remove both SNS.apk and SNS.odex
You can do these steps for any app you want to remove. If you are unsure
whether or not an app can be removed you can copy it to your sdcard first,
so if your phone breaks (causes alot of force closes) you can move it back to fix it
Code:
cp SNS* /sdcard/
rm SNS*
To move back
Code:
cp /sdcard/SNS* /system/app/

Backup your Market Applications
Say you want to flash a new rom, but you dont want to have to redownload all the applications again, you can copy your apps to your sdcard for future installation
Code:
mkdir /sdcard/Backup
cp /data/app/* /sdcard/Backup/

Your ToolBox
There is so much you can do with the shell its not even funny, I am getting tired of typing so instead of going thru everything I am going to finish up with a brief description of the things you can do.
Code:
cd - lets you move around, just like in dos to go to a new folder you 
would cd to it, to go to a folder in the same directory as your in its just cd 
folder/ to get to a folder with its abolute path, start with a
/ - [B]cd /data/app/[/B]
Code:
ls - ls lists whats in a directory, you can only display some results by 
issuing ls with an arguement, like [B]ls /data/ap*[/B] would return all results 
in /data/ that start with ap
Code:
cp - cp is for copying files, the syntax is cp original desination (cp 
/data/app/com.app.fake.apk /sdcard/ if you dont specify a name for the 
desitination it will use the same name. To copy a whole folder you must 
use the -r option [B]cp -r /system /sdcard/[/B]
Code:
mount - used to "mount" or gain access to different blocks (partitions) 
the most common command you will be issuing is [B]mount -o remount,rw -t yaffs2 
/dev/block/mtdblock4 /system[/B] which will allow you to make changes in the 
/system/ partition
Code:
rm - remove, delete, its simple enough accepts * (wildcards). To remove 
a directory you must use the -r option [B]rm -r /system[/B] (dont do that as an 
example)
Code:
df - short for diskfree this shows how much space if left on partitions
Code:
free - shows how much available RAM you have

Other cool ADB stuffs
To exit an ADB shell just type exit until you see your DOS window. there are other ADB commands you can issue from the DOS prompt.
Code:
[B]adb reboot recovery[/B] - this will reboot your phone into recovery, 
no more pulling batteries!
Code:
[B]adb pull[/B] - grab files off your phone and dump them in the directory 
your in, syntax [I]adb pull /path/file[/I] eg. 
[B]adb pull /system/framework/framework-res.apk[/B]
Code:
[B]adb push[/B] - pretty much the same a pull but for putting files 
on your phone, one problem I run into with the ally is that you cant push 
anything directly to /system so to put something into /system you will 
have to put it on /sdcard/ first then cp it over from a shell. [I]adb push 
local file /remote/path/file[/I] eg[B]adb push framework-res.apk /sdcard/[/B]

Wait: There's more
As previously stated, this is just the tip of the iceburg, something to get you going and so
your not lost when dots asks you to run some terminal commands on IRC. With this
basic knowlege you can already do things like: change your boot animation, mod
framework for some self-theming, and so much more

update
Adding ADB to your PATH variable
So now that you have been using adb for awhile you have probably realized that its a PITA to move files around since you have to be in the SDK directory to run commands. Well guess what?!!? You can make it so you can use adb and fastboot commands from any folder on your PC
To do this on windows:
  • Hold down the Windows Key (you know the annoying one on the bottom right that you always press when your playing games on accident) and strike the Pause|Break key (up towards the top left above number pad) - This will open up System control menu, you can also get here from the Control Panel (System) or right clicking (My) Computer and selecting properties.
  • Now on Vista/7 you click Advanced System Settings (on the left) on XP there is a tab called Advanced
  • Click the button on the bottom called Environment Variables
  • There are 2 boxes here, user and system. Inside the system box you will see allot of variables scroll down and look for Path when you see it Double Click it, or Edit
  • You will see here allot of paths each ending in a ; to separate. Go to the end, make sure there is a ; after the last entry, and put the path to your SDK tools, mine is E:\android\sdk\tools;, yours will probably be C:\android-sdk-windows\platform-tools; make sure it is the directory where adb.exe and fastboot.exe are! If your unsure navigate to the directory with explorer and check.
Thats all folks, now when you open a command prompt (cmd) you can use adb anywhere! (fastboot too)
 
This is an awesome write up man. This will help so many people in the future. That is if people aren't scared to get their hands a little dirty. lol
 
This is very handy, i only wish you had did this months ago. When i 1st rooted my wifes phone, i would equate it to going from driving a car to flying the space shuttle LOL
 
Subscribed...
And I think this thread should be stickied, there is a lot of useful info here. Yes, i know google can also give all of this info with the right search terms, but it's nice to have it conveniently placed right here.
 
Omg, Savoxis you are AMAZING! Thanks SO MUCH for this!! I needed it BAD!!
After I click 'post' I'm gonna click 'donate' :)
 
been having people ask me for links to this so:
BUMP

MODS:
If I include some info on setting up the SDK to make this a semi-complete guide think we can sticky it?
 
What if you didn't follow Tridents guide how do you get adb if you used Superone click rooting method
 
Back
Top Bottom