Getting Started with Android Development
In this topic:
- Before you start
- Choosing the module type you need
- Creating an Android project
- Adding an Android module to a project
- Attaching an Android facet to an existing Java module
- Configuring the code style of Android-specific XML definition files
Before you start
- Download and extract the Android SDK. We strongly recommend that the path to the Android SDK home directory does not contain spaces.
Add SDK packages. For detailed instructions and download links, refer to Adding SDK Packages.
Configure the Android SDK in IntelliJ IDEA, see SDKs.
Make sure that the bundled Android Support plugin is activated. This plugin provides Android support at the IntelliJ IDEA level and is enabled by default. If not, enable it as described in Managing plugins.
Depending on your task, choose the module type you need for your Android development.
- Create a project with an Android module from scratch, add an Android module to a project, or attach an Android facet to an existing Java module.
Depending on the chosen module type, IntelliJ IDEA automatically sets up the correct module structure with the res and gen folders, downloads the necessary libraries, and generates various Android-specific descriptors.
Choosing the module type you need
IntelliJ IDEA lets you choose Application modules (form factors) when you create your project, add different Android modules to an existing project, or add Android facets to your modules.
Creating an Android project
In the menu, choose File | New | Project to open the New Project Wizard. In the left-hand pane select Android .
In the right-hand pane configure your new project and click Next.
On the next page of the wizard, select the application module type and its minimum SDK. Click Next.
On the next page of the wizard, select the Android activity and click Next.
On the next page of the wizard, specify the Activity settings and click Finish.
Adding an Android module to a project
- Choose Project tool window.
The New Module wizard opens. from the main menu or from the context menu of the
In the left-hand pane, select Android. In the right-hand pane, select a module you want to add and click Next.
On the next page of the wizard, specify the application or library name, module name, package name and a minimum SDK that is required for this type of application. Click Next.
On the next page of the wizard, select an activity for your module and click Next.
On the next page of the wizard, specify the settings to customize the selected activity and click Finish.
Attaching an Android facet to an existing Java module
You need to perform this procedure if you want to attach an Android facet to an existing Java module. Android modules have this facet applied by default.
Open the Project Structure dialog (e.g. Ctrl+Shift+Alt+S).
Under Project Settings, select Modules.
Select the module you want to add an Android facet to, click , and choose Android.
- On the Facet 'Android' page that opens, specify the location of the key application components in the Structure tab: the AndroidManifest.xml file, the application resources, the application assets, and the Android native libraries..
If necessary, you can edit the default paths. To return to the default Android facet settings, click Reset paths to defaults.
To make the module source code and resources available from other projects, select the Library module checkbox on top of this page.
Configuring the code style of Android-specific XML definition files
Android development involves working with dedicated XML files, such as layout and resource definition files, manifest files, etc. You can have IntelliJ IDEA apply the standard XML code style to such files, or configure custom code style settings for them.
Open the Settings / Preferences Dialog by pressing Ctrl+Alt+S or by choosing for Windows and Linux or for macOS. Expand the Editor node, and then click XML under Code Style.
On the Code Style:XML page that opens, switch to the Android tab.
- Do one of the following:
To define a custom code style for Android-specific XML files, select the Use custom formatting settings for Android XML files checkbox and configure the settings to be applied to various types of Android XML files using the controls of the tab as described in Code Style:XML - Android.
To have IntelliJ IDEA format Android-specific XML files according to the standard XML code style settings defined in the other tabs of the page, clear the Use custom formatting settings for Android XML files checkbox.