Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,781,728 Members 43,958 Now Online
XDA Developers Android and Mobile Development Forum

[GUIDE] Using ADB & FASTBOOT in OSX / Mac

Tip us?
 
siedkins
Old
(Last edited by siedkins; 27th January 2011 at 01:06 AM.)
#1  
Senior Member - OP
Thanks Meter 76
Posts: 291
Join Date: Jul 2008
Location: London
Default [GUIDE] Using ADB & FASTBOOT in OSX / Mac

Hi,
I thought I'd add this here because I've recently starting using OSX after building my own hackintosh out of PC parts. I got very fed up with Windows and the need for drivers all over the shop so I'm moved over now.

I've also just got into flashing my HTC Desire and it was made very easy by lots of the guys here. One thing that will always be useful when rooting and flashing your phone is ADB. There are lots of guides out there for ADB on Windows but I wanted to run in natively in OSX.

After a lot of research and a few failed attempts .... I've now worked out how to run ADB in OSX.

What you will need:
A Mac
USB cable
Android SDK for OSX- http://developer.android.com/sdk/index.html

At the time of writing this the version was "android-sdk_r08-mac_86" so please have a look at the above link and let me know if you can't find that same version.

So download the zip file and I would extract it to a folder where you are happy to keep it such as within your user home folder i.e. Macintosh HD/Users/{Your User Name} and for my mac it is Users/siedkins which is how I have my OSX set up.

Then open then still in Finder, open "android-sdk-mac_86" then "tools".

Now launch Terminal - ⌘ + space then type Terminal or Applications>Utilities>Terminal

Now drag and drop the file called "android" in the "tools" folder into your terminal window and you should see something like:
/Users/siedkins/android-sdk-mac_86/tools/android

Then hit enter - this should load Android SDK

Next go to Available Packages on the left and Android Repository > Android SDK Platform-tools, revision 1 -tick the box and hit "Install Selected"

It should download and install the Platform Tools which includes ADB !!!!

Now quit Android SDK after it has downloaded and go back into Finder. Now you should see a new folder "platform-tools" in the "android-sdk-mac_86" folder. Open that and you can now see a file called adb.

Now .... I am going to show you how to make your life a lot easier in Terminal to run ADB without having to navigate to the folder every time you want to launch it.

Go back to your Terminal window and type (or copy & paste):
Code:
cd ~
The screen should then look like
NAME_OF_YOUR_MACHINE:~ USERNAME$

For me I have:
Mac-Pro:~ siedkins$

Next, type
Code:
touch .bash_profile
to create your new bash / path file

Next, type
Code:
open -e .bash_profile
to open it in TextEdit.

Now into Text Edit please copy:
Code:
export PATH=${PATH}:
Then go into Finder and navigate your your "android-sdk-mac_86" folder. Then click on the "platform-tools" folder and drag and drop this into TextEdit at the end of the code above that you copied. Mine looks like:
export PATH=${PATH}:/Users/siedkins/android-sdk-mac_86/platform-tools/

Yours should look like:
export PATH=${PATH}:insert your path to the "platform-tools" folder in your Android SDK here

All you need is that one line. Then Save and exit TextEdit and then very importantly QUIT TERMINAL.

***** If you have issues being able to save the file at all then please jump to the bottom of the post*****

Now ........ to turn on USB Debugging in your handset Settings > Applications > Development > USB Debugging - ticked and also go to Settings > Connect to PC > Default connection type > Charge Only and also UNTICK "Ask me ..." there also. You can always go back here and change these settings back.

Now plug in your phone to a USB port. I noticed that if I plugged my phone into one of the standard USB ports on the front of my machine I couldn't see the phone further down the line and if I plugged it into a powered USB port on the front (I have an "akasa AK-ICR-08" which has a powered connector behind the 5 USB ports. But you guys will probably be using a MacBook or MacPro and there shouldn't be any issues with the power to your USB ports.

Now to launch ADB - re-open terminal (remember that you had quit it - very important!) then type in:
Code:
adb devices
And you should see:
List of devices attached
HXXXXXXXXXX device


where XXXXXXXX is your unique phone ID.

Now you can run all of your favourite ADB commands straight by typing:
adb shell

etc straight into Terminal. I won't go into that here as there are plenty of guides about what to do with ADB once it's installed!



Now you have ADB setup on your Mac and can run it without the need for installing HTC Sync - un-installing it - loading some modified drivers over the top !!!!

It all just works !!!!!!

Please drop me a line if you have any queries about this !


******************


If you are have user account issues such as Terminal or TextEdit says that you can't do anything then try adding "sudo" to the front of your terminal command as this will allow you to execute the account as a superuser or root user for OSX! ROOT!!! Note that you will have to enter your password to enable the superuser access rights and you won't see anything as you type in your password.

i.e. try:
Code:
sudo touch .bash_profile
then
Code:
sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit .bash_profile
(slight change in the coding here to ensure that TextEdit opens

Or you could do:
Code:
sudo pico .bash_profile
This will open up the Pico text editor instead of TextEdit. Here you will have to type out all of the text then you press "ctrl+x" to exit and then you can save on the next screen. To check that has worked you can then open the file in terminal again and check it with the normal command:
Code:
open -e .bash_profile
******************

Please see post #37 for How To Use ADB Over WIRELESS !!!!

************************************************** **********************
EDIT - 27th JAN 2010

FastBoot

I've now found you all a precompiled version of Fast Boot:
http://developer.htc.com/adp.html

Please download and unzip the precompiled version for OSX to your "SDK/platform-tools" folder.

Rename the unzipped file from "fastboot-mac" just to "fastboot". You need to fix the permissions of the fastboot file using CHMOD in Terminal.

In Terminal navigate to your "SDK/platform-tools" folder and then type:
Code:
ls
You should see all of the files in your "platform-tools" folder such as adb, aapt, fastboot, etc.

Then type:
Code:
chmod 777 fastboot
PLEASE NOTE THAT I AM ASSUMING THAT YOU HAVE CHANGED THE FILE NAME ABOVE !

Now with the permissions fixed you should be able to run fastboot.

Connect your phone via USB and set to "charging only". Then turn off your phone and leave the USB in. Then hold the back key and then turn your phone on again. You will have a white screen with 3 skateboarding androids on.

Now in Terminal type:
Code:
fastboot devices
And you should see your unqiue phone ID! (Note that you have to be at that white screen with the skateboarders for the "fastboot devices" code to run!

Now you have a fully working fastboot !!!

Sorry this explanation is a bit short - I did write out a longer one but my browser crashed and I lost it all. However if you cannot follow the above then I think it's maybe best that you don't use fastboot as you could seriously brick your phone.

NOTE - I HAVE NEVER USED FASTBOOT TO FLASH A RADIO OR PHONE SO I PROBABLY WON'T BE ABLE TO HELP IF YOU GET ERRORS IN USING FASTBOOT OR FLASHING YOUR DEVICE ! The above information is how to shortcut the navigation to the folder. Please don't blame me if you break the recovery image of your phone!
LG G2 (802) (Vodafone UK)
ROM - Stock
-------------------------------------------
Samsung Galaxy Nexus GSM (Orange UK)
ROM - CM10.2
Kernel - franco.Kernel (nightly)
-------------------------------------------
HTC Desire (Orange UK)
Rooted using unrevoked / 4Ext Recovery / CM71.0 / CM7r2 HBoot / ManU 2.0.1 Kernel
-------------------------------------------
My Guide To Using ADB & Fastboot On OSX/Mac
The Following 44 Users Say Thank You to siedkins For This Useful Post: [ Click to Expand ]
 
dhoshman
Old
#2  
Senior Member
Thanks Meter 34
Posts: 253
Join Date: Jul 2010
Location: Indianapolis
Thanks for such a thorough step by step guide. But Im having a problem I followed the directions and at the last step I get "permission denied". Any tips for me would be truly appreciated. Thanks
 
drgopoos
Old
#3  
Senior Member
Thanks Meter 477
Posts: 2,304
Join Date: Jul 2007
Quote:
Originally Posted by dhoshman View Post
Thanks for such a thorough step by step guide. But Im having a problem I followed the directions and at the last step I get "permission denied". Any tips for me would be truly appreciated. Thanks
which last step ?
 
madj42
Old
(Last edited by madj42; 19th December 2010 at 05:34 PM.)
#4  
Senior Member
Thanks Meter 26
Posts: 206
Join Date: Jun 2010
Location: Minnesota
Quote:
Originally Posted by dhoshman View Post
Thanks for such a thorough step by step guide. But Im having a problem I followed the directions and at the last step I get "permission denied". Any tips for me would be truly appreciated. Thanks
What version of MacOS? Also are you sure your device is properly rooted? I'm assuming you are getting the error when typing "adb devices"?

EDIT: That's what I get for being distracted while typing this.. ;)
_thalamus Old
#5  
Guest
Thanks Meter 0
Posts: n/a
The easiest way to get the sdk is by using homebrew, which is an amazingly useful tool. https://github.com/mxcl/homebrew

Code:
brew install android-sdk
It doesn't add adb to your path however, you have to do that manually by adding /usr/local/Cellar/android-sdk/r8/platform-tools to your path.

Hope that makes it a little bit easier.
 
mun-key
Old
#6  
Member
Thanks Meter 0
Posts: 30
Join Date: Dec 2010
I found that on my mac using terminal I have to always start the adb commands with a ./ otherwise it wouldn't work right. This might be common knowledge for some, but I'm a terminal newbie

So, for example:

./adb devices
 
manleyaudio
Old
#7  
manleyaudio's Avatar
Senior Member
Thanks Meter 95
Posts: 239
Join Date: Oct 2010
Location: Seattle
Thumbs up Thanks for the walk through

This work great. I put the the SDK folder on the root of Macintosh HD and renamed it to AndroidSDK. Then in the .bash_profile my path was /AndroidSDK/platform-tools/ . I then made a backup of my SD card with adb pull from /mnt/sdcard to my local machine.
 
madj42
Old
#8  
Senior Member
Thanks Meter 26
Posts: 206
Join Date: Jun 2010
Location: Minnesota
Quote:
Originally Posted by mun-key View Post
I found that on my mac using terminal I have to always start the adb commands with a ./ otherwise it wouldn't work right. This might be common knowledge for some, but I'm a terminal newbie

So, for example:

./adb devices
Kind of weird. To me that would mean that you're path variable isn't setup correctly. Usually the ./ before a command means to run the command from the current directory and ignore the path variable.
 
Krisrk
Old
#9  
Member
Thanks Meter 1
Posts: 34
Join Date: Apr 2007
Location: Miami, FL
It doesn't even have to be this complicated. Download the sdk, whatever files you want to push to your phone put it in the same folder. Then do the commands (./adb push). Simple.
 
Syntax-Influx
Old
#10  
Junior Member
Thanks Meter 0
Posts: 6
Join Date: Jul 2010
Great and easy tutorial! Got it working in 5min ^_^

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes