Android App development on a Mac

I started with Android development yesterday, and getting to run the Android App on my phone took some struggle. I hope that this post helps the naive android developers to get started with building their first App.
OSx version : Yosemite 10.10.1

For developing an Android App, you need the following to be installed.

Install Java

First check whether Java is installed or not. On your terminal, type

$java -version

If you have Java 6.0 or above, you can skip to setting JAVA_HOME, else please download JAVA SDK from Java install page

Now set JAVA_HOME in your ~/.bash_profile to following:

export JAVA_HOME=$(/usr/libexec/java_home)
export JDK_HOME=$(/usr/libexec/java_home)

On the terminal window, type the following command:

$ source ~/.bash_profile

Install Android Studio

Get started by downloading Android Developer Studio. You can get this from the Android Developers Site.
After setting up Android Studio as per the instruction given on the site, you can get started by developing your first Android project.

Setting up USB debugging on your Android device

Plug in your device to your Mac and then enable USB debugging on your phone. This can be found in Developer Options on your android phone. Note that, the developer options is hidden by default on Android devices with version 4.2 and above.

To find the secret menu, click on settings App. Scroll down to About Phone.

Then go down to Build Number and tap on that 7 times.

Then when you go back to settings, you will see the developer options menu appear.

Enable USB debugging on device.

Getting you Mac to detect your Android device

Ideally, your Mac should detect your phone by default. However, for some reason, this may not happen. Follow the following steps to make your Mac detect your phone.

1. Make sure that adb(Android Developer Bridge) is included in your path. The default location for adb is:

~/Library/Android/sdk/platform-tools/

2. Include the following line in your .bash_profile.

export PATH=/usr/local/sbin:$PATH:~/Library/Android/sdk/platform-tools/

3. On the terminal window, type the following command:

$ source ~/.bash_profile

4. Next add the Vendor ID to ~/.android/adb_usb.ini. But first you have to find the Vendor ID value. You can do this from the System Information Application. Fortunately on Mac this is pretty easy. Launch the System Information application.
From the Hardware Menu in the left pane -> Select USB -> In the right pane, you will see the list of USB devices, select your phone from it -> In the lower pane on the right, you will see the vendor id. Copy this vendor id to the file ~/.android/adb_usb.ini

5. Restart adb

$ adb kill-server
$ adb devices

The device should be listed.

Thats it, you are all set for developing android apps and testing them on your mobile

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s