FAQS: Setting Up the Android Development System on Mac OSX 10.6.5What language do I need to know?You will want to develop a working knowledge of the Java language.
What is Android?Android 2.2 is a mobile operating system based on a version of the Linux kernel running Java applications on a JIT register-based virtual machine.
Where do I start?Consider starting at the Android Developers website.
I cannot find the JDK for Mac on the Sun website?It is part of the Mac OSX 10.6 install.
Should I download the 32 bit or 64 bit version of Eclipse IDE for Java EE Developers (Helios)?The 64 bit version must be capable of producing 32 bit applications. It may be simpler to download the 32 bit version.
Where do I get the Android SDK?Mac Android SDK.
How do I install the ADK plugin?ADK plugin.
What platform did I install?Using the Android SDK and AVD Manager (android-sdk.../tools/android), I installed Android 2.2 to target my phone, the Evo 4G.
How do I navigate using the Terminal (Applications --> Utilities --> Terminal)?Be careful. You can do a lot of damage using the bash shell (Terminal) as the Administrator. Launch the Terminal program.
Find a manual that explains some of the bash commands such as:
ls | List visible contents of the current directory
|
cd ..
| Go up one directory level
|
cd ~
| Go to the home directory
|
cd /
| Go to the top level directory
|
cd <someDirectoryBelow>
| Go to <someDirectoryBelow>
|
ls -la
| List ALL contents of the current directory including hidden files that start with a '.'
|
Fig. 1: The Bash Terminal
How can I edit a file such as ~/.bash_profile?Be careful. You can do a lot of damage using the bash shell (Terminal) as the Administrator. Launch the Terminal program.
You could use an editor such as vi. Open the Terminal and type:
vi ~/.bash_profile
Find a manual that explains some of the vi commands such as:
You can exit at any time by typing: | <Esc>ZZ |
You can save your work at any time by typing: | <Esc> :w <Enter> |
You can enter the text (insert) mode by typing: | <Esc> i |
You can delete from the cursor to the end of the current line by typing: | <Esc> D |
Typing <Esc> just puts you in the command mode, so it does not hurt to use it before a command if in doubt.
Remember <Esc> takes you to the command mode and <Esc> i will take you to the insert mode.
Fig. 2: Using the vi editor to edit my .bash_profile.
So you use vi to create and edit the ~/.bash_profile file. You add a line that appends the tools directory and platform-tools directory to the bash PATH. This will allow you to use the Android tools such as adb from the command line without the need to navigate to the tools or platform-tools directory. The changes to the PATH will not be honored until a new instance of the terminal is launched.
How do I know that my append to PATH command in the .bash_profile was read into the PATH?Restart the bash Terminal. In the bash Terminal type: echo $PATH to see if your changes to the PATH have been incorporated into the bash shell $PATH variable.
Fig. 3: The echo command used to display the appended $PATH variable.
How do I create a Hello, World program?Hello, World. Be patient! It takes a while for the Android Virtual Device to boot up and load your Hello, World application. You do NOT need to quit the emulator between builds!
Fig. 4: A screen-shot of the Hello, Android program running in the Android VM.
Why do I need to create an Android Virtual Device (AVD) under Eclipse?To run your Android programs under Mac OSX, you need to create a virtual environment on the Mac that mimics the Android phone environment. It is also possible to debug directly from your device over USB.
How do I change the screen size used by the emulator?Go to Window --> Android AVD Manager --> Virtual Devices Select AVD --> Select Edit --> Select Skin: Built-in HVGA (for 160) --> Edit AVD to save.
How do I scale the AVD to fit on my laptop screen?Go to Run --> Run Configurations... -->Target tab --> Scroll until you see Additional Emulator Command Line Options --> enter -scale <0.1 to 3> --> Apply
What is an Android Test Project?This will create a unit test application. Unit tests allow automated testing of your Android units of code. Anytime you change your Android application, you can run the unit test to see if your changes may have inadvertently invalidated the application's unit specifications.
After I edit the strings.xml file, I get the error 'Error in an XML file: aborting build.'?Its a newbie gotcha. Don't run the compiler when the strings.xml file is the active window. To repair the damage, delete the empty newly created strings.out.xml file. Click on the .java source code window and now run the compiler.
I deleted the strings.out.xml file and I still cannot compile my project. What is up with that?You may need to delete the error in the Problems pane by right clicking on the old error. OR maybe you really do have an error in an XML file!
OK, I was able to run the Hello, World program using the XML-layout UI, but now my changes to the string.xml file are not honored when I go to Run --> Run. What is up with that?For some reason, the Eclipse IDE sometimes appears to save, but does not recompile the strings.xml or main.xml files. I have not found a consistent solution yet. You can try saving, quitting and restarting the IDE. You can try cleaning the project. Sometimes you need to close the open files in the editor to force the IDE to actually save the changes. (TIP: If there is an XML parse error, the R.java file may not be updated. Look for a red flag implying an error in the XML files.)
Sometimes my java code changes are not honored. What's up with that?Try cleaning the project Project --> Clean. Try closing any open java files.
My App suddenly broke and all the calls to R.id.* are not recognized?It is a bug! Eclipse erroneously added 'import android.R' statement in the flagged file, remove the statement and close the file to save the changes.
How do I set a break-point in the Java code?Right click over the blue margin at the point that you wish the program to pause when in the debug mode and choose toggle break point.
How do I move from the Debug View to the Java View?On the right upper corner of the Eclipse window, click on Java.
Fig. 5: Eclipse IDE in Debug view. Right click on the blue margin to set a break-point.
I fixed a missing import, but my code will still not compile. What to do?You may need to manually delete the errors in the problem window.
I need to import, but the IDE gives me two choices, one in the Android namespace and one in the java namespace. What is up with that?Use the Android namespace as the code has been optimized for mobile devices.
How do I transfer my application to my phone?You can use your phone for live debugging or transfer your application directly to your phone over USB.
How do I set debugging to true on my Evo 4G?Select Home --> Menu --> Settings --> Applications --> Development --> Enable USB debugging.
I connected my Evo 4G via USB and it is in the charging mode. How do I tell if the Mac OS recognized my phone?If you configured the $PATH variable correctly, you can just launch the terminal and type adb devices. This will list successfully attached
Android devices.
Fig. 6: Using adb to list Android devices attached to the Mac OS.
My device is recognized by the Mac OS. How to I debug my application 'HelloAndroid' on my phone?If you have compiled to the proper platform, you can debug on your phone by going to Run --> Debug Configurations... --> Android Applications --> HelloAndroid and select the Target tab. Now set the Deployment Target Selection Mode to manual and hit apply. Now hit the Debug button in the open window --> Choose a running Android device --> Select your phone and click OK. Your application now resides on your phone! To terminate the application choose Run --> Terminate
What is Ant?Ant is a command-line build tool that can be used to drive builds of Java applications. Ant configuration files are XML-based.
<ant>
</ant>
The Android system requires a certificate before an application can be installed on my phone. I did not create a certificate with my own private key, but my application did install on my phone when I used live debugging. How is this so?
When you did a live debugging a debug keystore and key was auto-generated and used to sign your application. The debug keystore and key was generated using public names and passwords. The debug certificate is not suitable for a release version.
How do I test my application in landscape mode using the emulator?
With the emulator running, hold down Ctrl-F11 to toggle between landscape and portrait mode.
Fig. 7: Emulator running in landscape mode.
My program works great on Android 2.2. How do I compile it to run on Android 1.5 and above (API 3+)?Run the Android program from the terminal. Download the Android 1.5 API. Go to Project --> Properties --> Android and choose Build Target Android 1.5. Click OK. Now change the manifest.xml file to reflect the change in target API. Be sure to test your project against the Android 1.5 emulator in addition to the Android 2.2 emulator. The ConfuseText app failed to launch under Android 1.5 but launched against Android 1.6 (API 4), Android 2.1 (API 7) and Android 2.2 (API 8).
I updated to the latest versions of the Android software and now my program will not compile with a message that I need to update to the latest version of ADT (Android Development Tools). When I try to launch the SDK and AVD manager I get a message saying the SDK cannot be found. How do I fix this situation?Consider going to Help --> Install New Software.. --> Click on the arrow Work with: --> Choose ADT Plugins --> Select Developer Tools --> Expand Developer Tools --> Click Next> to install.
Congratulations! If you followed the steps above, you have successful installed the Android Development System on your Mac, compiled an Android application and transferred it to your Android phone!
Have Fun!
JAL