I am listing two different rooting procedures here. The first does is simpler and does not require a computer, however the second also installs ClockworkMod Recovery for you which is needed if you plan on flashing ROMs/kernels/themes. If you use the first method and need Clockwork, you will have to install it separately. Both procedures work with 2.1 Eclair and 2.2 Froyo.
Procedure 1:
This is the simplest method and should be tried first.
1. Download
z4root from this link or from the Market.
2. Run the app on your phone and follow its instructions to gain root access.
If the app is not working, you may need to reboot or battery pull and try again.
One
Some users have had better luck by switching to the "Home" launcher and removing the SD card, then running z4root.
If after many attempts and trying the tips above you still cannot gain root access, try the procedure below.
Thanks to brandonc for posting about z4root
Procedure 2:
Do not expect this to work the first, second or even third time you try it. It is not uncommon for this procedure to fail multiple times before working. There are many variables involved and you may need to have a lot of patience while you go through the trial and error process of getting this to work. If at first you don't succeed...
1. Download and install the appropriate drivers for your Windows system:
32-bit drivers
64-bit drivers
2. Download
Android SDK, unzip it and place the "android-sdk-windows" folder and its contents in the root of your computer hard drive (so its location is C:\android-sdk-windows).
3. On your phone, push MENU, then select Applications > Development, then enable USB debugging and connect your phone to your computer via USB.
Credit for picture goes to
AhmgskMod
Note: the type of USB cord and the specific USB computer port can make or break your ability to successfully root. If you are getting errors in the command prompt during step 4, trying swapping USB cables and/or switching USB ports (even the USB cord that came with the phone can cause problems!).
4. Download and extract
one-click root w/Clockwork and run the file "run.bat" (note: this new version will not block the installation of Froyo through stock recovery). The Windows command prompt will come up and the process will start.
If the command prompt asks you to restart adb, you need to go into Windows Task Manager (ctrl-alt-del on your keyboard) and end adb in the process tab, then go into the folder you extracted from the "one.click.root.exploitv2.3.0.zip" and double-click on the "adb" file to restart adb.
If the command prompt says "device not connected", disconnect the phone and reboot it, turn debugging mode back on, reconnect the phone via USB, and rerun the "run.bat" file again. If you're still getting "device not connected", try repeating these steps one at a time or in a different order, for example just kill adb and rerun "run.bat" or only reboot the phone and then rerun "run.bat".
After Rooting
An easy way to confirm that the rooting process was successful is to download a free app called Titanium Backup from the Market - upon startup the app will tell you if you have root access. If a "Superuser" pop-up window appears when you start Titanium Backup, push "Allow".
What is Superuser? it is an app that was installed when you rooted. Anytime there is a request to modify a low-level file or folder on your phone, Superuser will let you know and give you the chance to confirm or deny it access. This is a safety measure. If you happen to download a malicious app, Superuser will stop it from modifying low-level data and notify you. If an app you trust is requesting root access, just check the "Always Allow" box and it won't ask you again.
Your phone is rooted, now what? If you plan on flashing a custom ROM and/or kernel and you used Procedure 1, then it's time to install
ClockworkMod Recovery (this method of installing Clockwork has only been tested on 2.1 Eclair). If you used Procedure 2, then just make a backup of your phone using Clockwork and you're ready to start flashing!