Next: , Previous: Java Features, Up: Top


12 Android Features

If you are building Android applications using CEDET, there are several features that can help with this task.

First, you need to download the android SDK. You can get that from http://developer.android.com/sdk/index.html. Make sure all the tools the android sdk needs has been installed.

12.1 Create an Android project

The Android SDK has a command called android which is used to do several things, one of which is to create a template project directory hierarcy. In order for Emacs to detect your SDK and find android, you may need to configure the CEDET android support.

— Function: cedet-android-sdk-root

The root to the android SDK.

You can then create a project from Emacs:

— Function: cedet-android-create-project name package target &optional dir

Create an android project with NAME. Your activity class will be created in the java PACKAGE. You need to specify a TARGET, which is a number specifying the desired type of package you intend to build. Create the project in optional DIR, or in the default directory if not specified. NAME will be used as the name of the project.

It may be better, however, to let EDE do it for you instead by calling ede-new. For example:

     C-x C-f ~/subdir/newprojectdir RET     ; go to an empty directory
     M-x ede-new RET                        ; Create the project.  Answer
                                              questions like name, etc.

12.2 EDE Setup

EDE will automatically detect android projects created with the AndroidManifest.xml file. The first time you visit a project, it is good to visit AndroidManifest.xml to make sure EDE will detect your project. Sometimes it can fail to detect your project if you visit a sub-directory of your project first.

EDE provides the following conveniences for android projects:

<C-c . e>
This will always jump to the AndroidManifest.xml file.
<C-c . c>
<C-c . C>
This will compile your project using ant. To change what type of build you do, you will need to change the current configuration. You can select a configuration such as install or release from the Project menu.
<C-c . D>
Debug your project. This will also start ddms, the debug proxy for your android emulator or device.
<C-c . E>
Visit a resource file from a buffer from a Java buffer. Cursor must be on the code representing the resource, such as:
          R.layout.mylayout

<c-c . A>
Visit a Java Activity buffer from the XML manifest file. Cursor must be in an activity element for Emacs to figure out which activity to visit.
<C-c . S>
Visit the strings.xml file from anywhere.
<C-c . g>
Rescan the AndroidManifest.xml file for version, package, etc.

There are other items in the menu as well, such as calling layoutopt to debug your layout files or starting the ADB shell.

EDE supports different build configurations through the standard EDE configuration mode. In the Project->Project Options menu, select “Default Configuration” and select one of the options. These options map directly to the command line arguments of ant, so if you select “debug”, then the compile command will be: ant debug.

debug
Builds the project in debug mode.
install
Builds the project in debug mode, and installs in your emulator or device.
release
Builds the project in release mode.

12.3 ADB Features

CEDET supports several calls to ADB, including the following:

cedet-android-adb-devices
Show the list of devices available.
cedet-android-adb-version-check
Check that the ADB install is supported by CEDET.
cedet-android-adb-shell
Create a shell buffer in Emacs which provides a unix-like shell into your running Android device or emulator.

12.4 Android Sample Projects

CEDET supports a handy way to find sample programs from the SDK.

— Function: cedet-android-visit-sample sample

Visit SAMPLE code in the Android SDK samples directory.

12.5 Android support for SRecode

You can create macros for use with android. Add the :android argument to your templates to get some android specific features.