Showing posts with label adb. Show all posts
Showing posts with label adb. Show all posts

7.30.2011

Setting up OS/X Path for Android Development and Logging

Let's assume the default shell is in use on Darwin, bash, and you have installed the Android SDK for OS/X, installed Eclipse and the ADT. Now the you need that nice set of tools in the Android SDK/platform-tools directory, it's a lot easier if you add them to your profile. I found this a nice easy way to do it, if you have the profile it will append if not it will create it: 1.) Open TextEdit

2.) If the Users/
/(YOUR_FOLDER)/.bash_profile - exists, then open this file. 3.) Assuming no previous path information exists, then type the following:
PATH=/Users/(SUBSTITUTE_YOUR_PATH)/android-sdk-mac_x86/platform-tools:$PATH
4.) Save the file as /Users/(YOUR_FOLDER)/.bash_profile - if this does not exist, or open the .bash_profile in step #1 if the file exists.

SETTING UP LOGCAT
This can be easily be done in Eclipse as another view, but I like having it running in a background Terminal on my Apple.

1.) Open a Terminal window.
2.) Type: adb logcat

You will get a window output similar to below (depending on your emulators, and what debuggers you have setup)

 



The line in the logcat output:
D/Suduku  (  538): Debug Msg: Exit Clicked

Is coming from the emulator running, and the code I added to my Android application for this debugging information is as follows:

    private static final String TAG="";
    private void msg(String s)
    {
        Log.d(TAG,"Debug Msg: " + s);   
    }

When the user presses the "Exit" - in the onClick() method I have added the call to the method msg() as follows:

            case R.id.exit_button:
                msg("Exit Clicked");
                finish();
                break;

This sends the string "Exit Clicked" to the method msg(), which then sends the string to the debugging variable TAG - captured in the logcat output.