How To: A beginners guide to Android’s ADB for Mac OSX.

As much as I piss and moan about people needing to install the Android SDK if they intend to mod their phone, I feel obligated to do a tutorial.

While the title specifically states “For Mac”, that really only applies to the installation. Once you have the SDK installed, the commands are more or less the same in ADB.

Installation (Mac Specific)

1. Download the SDK. It will come in the form of a zip. Extract it somewhere easy, like the root of your username. You’ll get a folder called “Android-sdk-mac_86″ or something similar.

2. In finder, navigate to the sdk, then find the tools folder. Open it, and double click “Android”. It will launch a terminal window, then a few seconds later, a GUI. On the left, click on “Available Packages”, then in the right pane, check the box to select all, and hit “install selected”.

It will download quite a bit of data, so depending on your connection speed, it may take a while. While you’re waiting on that, use my tutorial to set up a bash profile.

3. On your Android phone, go to Settings > Applications > Development, and make sure “USB Debugging” is checked. Connect your phone to your computer with the USB cable.

4. Assuming the SDK is fully installed and downloaded, close the terminal window it opened and the gui. Open a new terminal window. If you’re not sure how, press Command + Space and type “Terminal” then enter. You’ll get a black box with text. Type “adb devices” and press enter. If everything worked, it will return a device ID to indicate your phone is connected and detected by ADB.

Navigating Basics

In order to effectively use ADB, you need a basic grasp of navigating your computer from terminal. Opening a terminal session will start you at the root of your user name, in finder, this will be your user name in the left hand pane, right under “desktop”. Entering

~/

or

cd

will get you back here.

If you intend to flash an img, push a file, etc, the easiest way to do so is to navigate to the directory in which the file is located. For example, if you want to push (I’ll explain what “push” means in a few, just stay with me) a file that is located on your desktop, and is named yourfile.zip to the SD card on your phone, you can either use

adb push ~/username/desktop/yourfile.zip /sdcard

from anywhere in terminal, since you’re using the full path to the file, or you can first navigate to the file’s location:

cd desktop

and then

adb push yourfile.zip /sdcard

which doesn’t require the full path, but rather works from the current directory.

Either way, you need a basic idea either how to determine the full path of a file, or how to navigate to the file’s location. Let’s cover the basics.

cd – Change Directory. This is what you’ll use more than anything. The format is

cd (location)

For example, let’s say you have a folder on your desktop named “android”, and inside that folder you have a folder named “apps”. To get there from ~/, you would enter

cd desktop/android/apps

Now let’s verify our location in terminal.

pwd

Now use ls to list the files in that folder

ls

That pretty much covers the basics. A few shortcuts:

  • cd will take you back to the root of your name from anywhere
  • cd .. will take you up one directory
  • ls -a will show all files

ADB Commands

adb push

adb push will “push” a file from your computer to your phone. The format is

adb push (location on computer) (destination on phone)

For example, let’s say you navigate to your desktop, and you want to move the file “song.mp3″ to the folder “music” on your phone’s SD card.

adb push song.mp3 /sdcard/music/

adb pull

adb pull is exactly the opposite. To pull song.mp3 from the music folder on your sdcard to your desktop:

adb pull /sdcard/song.mp3 ~/desktop/

adb install

adb install will you install an app via adb, using an apk file on your computer. If you have app.apk downloaded to your desktop, and have navigated to desktop in terminal

adb install app.apk

You need to have “Unknown sources” checked on your phone, found at settings > applications for this to work.

adb logcat

adb logcat is insanely valuable in trying to diagnose issues. Simply enter

adb logcat

and you’ll start to get a real time log of everything going on with your phone. It might not mean much to you, but it can be a valuable tool when asking for help.

That’s all I feel like writing for now, I’ll cover ADB shell, fastboot, and perhaps more extensive stuff later. Hope this helps.

2 comments to How To: A beginners guide to Android’s ADB for Mac OSX.

You must be logged in to post a comment.