The present tutorial assumes that you have installed IntelliJ IDEA 12 Community Edition and have the Android SDK configured to create applications for the Android 2.2 platform. A lightweight IDE for Java development, IntelliJ IDEA Community Edition comes out-of-the-box with a plugin for Android development.
1. Launch the Create New Project wizard
From the IntelliJ IDEA home screen, start launching the Create New Projectwizard.
The next step takes you to choose the type of project you want to create: choose the type of Android module you want to build. Each choice corresponds to a different project template being created.
2. Select the project template
From the dialog box in the figure, you choose the project template and then enter essential information about the project to be created.
The most common choice is an Application Module. This option will take IntelliJ IDEA to arrange a project with some predefined structure. Basically, you can just compile the project as is and still get a nearly empty but fully functional Android application. If you choose the Empty Module option then IntelliJ IDEA will simply deliver an empty project only configured to build for the specified Android platform. No extra content will be generated. Finally, the Library Module option prepares the ground for building a class library of shared code.
Let's go for an Application Module and enter project name and destination folder. More importantly, you should choose the target Android platform. The drop-down list is prefilled with all of the platforms you selected through the SDK Manager. Clicking Next takes you to a summary dialog box.
In case the Java SDK and/or the Android SDK are not installed or are configured in a bad manner, you may run into some troubles. To fix these possible issues and make IntelliJ IDEA point correctly to the Java SDK and Android SDK, you can click File → Project Structure:
3. Edit project properties
The dialog box below summarizes the application name and package name and allows you to set the target device and start-up activity.
The package name should be in the form com.xxx.yyy, where xxx usually stands for the company name and yyy is just the application name. You can use any names here, but the suggested pattern reduces significantly the risk of name conflicts with other applications.
IntelliJ IDEA offers to create a sample activity named MyActivity. In Android development, an activity is a plain Java class and an essential component of any Android applications.
4. Set the target device
The dialog box also gives you a chance to define how the sample application should be run by IntelliJ IDEA. There are three basic run configurations:
- Show device chooser dialog indicates that IntelliJ IDEA will ask you to choose between the emulator or a device connected via USB every time you launch the application from the IDE.
- USB device indicates that IntelliJ IDEA will automatically try to deploy the application to any compatible device available through a USB port. This is the option you use if you want to test on a physical device.
- Emulator indicates that IntelliJ IDEA will deploy the application to the configured emulator. Note that you also need to set up an Android Virtual Device (AVD) to run applications in the emulator. We'll take care of this step in a few moments.
When ready, click Finish to have the project created.