http://blog.springsource.org/2010/12/17/spring-android-and-maven-part-1/ ********************************** * Spring Android Showcase ********************************** Introduction ------------ This project requires set up of the Android SDK, command line tools, Maven, the Maven Android Plugin, and Android Maven artifacts such as Spring dependencies. This document walks step by step through that setup. Development Environment ----------------------- The Android SDK is required for developing Android applications. Google provides command line tools, and an Eclipse plugin for building Android applications, however you are not restricted to only those options. The Maven Android Plugin makes use of the Android SDK command line tools to compile and deploy the app to the emulator, so there is no need for a separate IDE setup or configuration. Install the Android SDK ----------------------- Download the correct version of the Android SDK for your operating system from the Android web site: http://developer.android.com/sdk/index.html Unzip the archive and place it in a location of your choosing. For example on a Mac, you may want to place it in the root of your user directory. See the download web site for additional installation details. Add Android to your Path Example: a .bash_profile on a Mac: $ export ANDROID_HOME=~/android-sdk-mac_x86 $ export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools Install Android SDK Platform ---------------------------- The Android SDK download does not include any specific Android platform SDKs. In order to run the sample code you need to download and install the Android 2.3.1 SDK Platform (API Level 10). You accomplish this by using the Android SDK and AVD Manager that was installed from the previous step. Open the Android SDK and AVD Manager window: $ android Note: if this command does not open the Android SDK and AVD Manager, then your path is not configured correctly. Select Available packages from the left hand column Select the checkbox for Android Repository in the main window Select SDK Platform Android 2.3.3, API 10, revision 1 Click the Install Selected button to complete the download and installation. Note: you may want to simply install all the available updates, but be aware it will take longer, as each SDK level is a sizable download. Configure an Android Virtual Device ----------------------------------- http://developer.android.com/guide/developing/tools/avd.html Open the Android SDK and AVD Manager window: $ android Select Virtual devices in the left hand column and click the New button Enter 10 in the Name field Select Android 2.3.3 API Level 10 in the Target selector Click Create AVD to finish Note: The sample application is configured to look for an AVD with the name "10". Otherwise, you can name the AVD whatever you like. Using "10" for the name simply is a visual indicator of which API level it uses. Build and Run the Server app ---------------------------- $ cd spring-android-showcase/server $ mvn clean install Deploy the .war to a Servlet 2.5 or > ServletContainer. This can be done via Maven on the command-line by running: $ mvn tomcat:run Make sure the server is running on application context /spring-android-showcase-server Build and Run the Android Client -------------------------------- $ cd spring-android-showcase/client $ mvn clean install $ mvn android:emulator-start IMPORTANT: Ensure the emulator is fully initialized and ready or the deploy will fail. $ mvn android:deploy View Logging $ adb logcat Tuning Emulator Performance -------------------------------- If the Android emulator is running sluggishly, you can try editing your AVD configuration with the following settings: - Check Snapshot: Enabled - Set the 'Device ram size' property to 1024. Troubleshooting Failed Deployment --------------------------------- If 'mvn android:deploy' fails, try stopping and restarting the adb server: $ adb kill-server $ adb start-server $ mvn android:deploy Unix Config ------------ make sure ~/.bashrc or ~/.bash_profile ~/.profile export M2_HOME=/opt/local/share/java/maven2 export MACPORTS_HOME=/opt/local/share export ANDROID_HOME=/Users/markkelly/Downloads/android-sdk-macosx AND /etc/launchd.conf (May not be created yet) has setenv M2_HOME XXXX (e.g. /opt/local/share/java/maven2) setenv ANDROID_HOME XXXXX (the location of the SDK android folder)