page.title=In Other IDEs @jd:body
The recommended way to develop an Android application is to use Eclipse with the Android Development Tools (ADT) plugin, provided in the SDK. The ADT plugin provides editing, building,and debugging functionality integrated right into the IDE.
However, if you'd rather develop your application in another IDE, such as IntelliJ, or use Eclipse without the ADT plugin, you can do that instead. The SDK provides the tools you need to set up, build, and debug your application.
The Android SDK includes activityCreator
, a program that generates a number of stub files for your project, as well as a build file. You can use the program to create an Android project for new code or from existing code, such as the sample applications included in the SDK. For Linux and Mac, the SDK provides activitycreator
and for Windows, activityCreator.bat
, a batch script. Regardless of platform, you can use activitycreator
in the same way.
To run activityCreator
and create an Android project, follow these steps:
tools/
directory of the SDK and create a new directory for your project files. If you are creating a project from existing code, change to the root folder of your application instead. Run activityCreator
. In the command, you must specify a fully-qualified class name as an argument. If you are creating a project for new code, the class represents the name of a stub class that the script will create. If you are creating a project from existing code, you must specify the name of one Activity class in the package. Command options for the script include:
--out <folder>
which sets the output directory. By default, the output directory is the current directory. If you created a new directory for your project files, use this option to point to it. --ide intellij
, which generates IntelliJ IDEA project files in the newly created projectHere's an example:
~/android_linux_sdk/tools $ ./activityCreator.py --out myproject your.package.name.ActivityName package: your.package.name out_dir: myproject activity_name: ActivityName ~/android_linux_sdk/tools $
The activityCreator
script generates the following files and directories (but will not overwrite existing ones):
AndroidManifest.xml
The application manifest file, synced to the specified Activity class for the project.build.xml
An Ant
file that you can use to build/package the application.src/your/package/name/ActivityName.java
The Activity class you specified on input.your_activity.iml, your_activity.ipr,
your_activity.iws
[only
with the -ide intelliJ
flag] intelliJ project
files. res/
A directory to hold resources. src/
The source directory.
bin/
The output directory for the build script.You can now move your folder wherever you want for development, but keep in mind
that you'll have to use the adb program in the tools/
folder to
send files to the emulator, so you'll need access between your solution and
the tools/
folder.
Also, you should refrain from moving the location of the SDK directory, since this will break the build scripts (they will need to be manually updated to reflect the new SDK location before they will work again).
Use the Ant build.xml
file generated by
activityCreator
to build your application.
Note: When installing JDK on Windows, the default is to install in the "Program Files" directory. This location will cause ant
to fail, because of the space. To fix the problem, you can specify the JAVA_HOME variable like this: set JAVA_HOME=c:\Prora~1\Java\
. The easiest solution, however, is to install JDK in a non-space directory, for example: c:\java\jdk1.6.0_02
.
As you begin developing Android applications, you should understand that all Android applications must be digitally signed before the system will install them on the emulator or an actual device.
The Android build tools help you get started quickly by signing your .apk files with a debug key, prior to installing them on the emulator. This means that you can compile your application and install it on the emulator without having to generate your own private key. However, please note that if you intend to publish your application, you must sign the application with your own private key, rather than the debug key generated by the SDK tools.
To sign your applications, the ADT plugin requires the Keytool utility included in the JDK. To set up your development environment for signing, all you need to do is make sure that Keytool is available on your machine that the build tools know how to find it.
In most cases, you can tell the SDK build tools how to find Keytool by making sure that your JAVA_HOME environment variable is set and that it references a suitable JDK. Alternatively, you can add the JDK version of Keytool to your PATH variable.
If you are developing on a version of Linux that originally came with Gnu Compiler for Java, make sure that the system is using the JDK version of Keytool, rather than the gcj version. If keytool is already in your PATH, it might be pointing to a symlink at /usr/bin/keytool. In this case, check the symlink target to make sure that it points to the keytool in the JDK.
In all cases, please read and understand Signing Your Applications, which provides an overview of application signing on Android and what it means to you as an Android application developer.
To run a compiled
application, you will upload the .apk file to the /data/app/
directory
in the emulator using the adb tool as described here:
<your_sdk_dir>/tools/emulator
from the command line)adb install myproject/bin/<appname>.apk
to upload
the executable. So, for example, to install the Lunar Lander sample, navigate
in the command line to <your_sdk_dir>/sample/LunarLander
and type ../../tools/adb install bin/LunarLander.apk
Note: When you install an Activity for the first time, you might have to restart the emulator before it shows up in the application launcher, or other applications can call it. This is because the package manager usually only examines manifests completely on emulator startup.
This section describes how to display debug information on the screen (such as CPU usage), as well as how to hook up your IDE to debug running applications on the emulator.
Attaching a debugger is automated using the Eclipse plugin, but you can configure other IDEs to listen on a debugging port to receive debugging information.