Skip to content

IntelliJ – Maven – Android – Git

This is a guide for setting up Java SDK, IntelliJ, Git, Maven and Android to bee able to develop Android Apps with IntelliJ and Maven and to save it on Github, http://github.com/. I wrote this guide setting it up on a virtual Windows Server 2003 R2 (32-bit) machine running in VMware Player.

Prerequisites

You have an account at Github, http://github.com.

Git

I choosed msysgit, http://code.google.com/p/msysgit/. You can also use Cygwin, http://www.cygwin.com/.

Install msysgit

I choosed Git-1.7.9-preview20120201.exe. There is an installation guide for Git for Windows at http://help.github.com/win-set-up-git/.

  • Welcome to the Git Setup Wizard: click next
  • Information (license): click next
  • Select Destination Location: leave default and click next
  • Select Components: check/uncheck as follows and click next
    • Additional icons: checked
      • In the Quick Launch: checked
      • On the Desktop: checked
    • Windows Explorer integration: checked
      • Context menu entries: checked
        • Git Bash Here: unchecked
        • Git GUI Here: unchecked
      • git-cheetah shell extension (32-bit only): unchecked
    • Associate .git* configuration files with the default text editor: checked
    • Associate .sh files to be run with Bash: checked
    • Use a TrueType font in all console windows (not only for Git Bash): unchecked
  • Select Start Menu Folder: leave default and click next
  • Adjusting your PATH environment: check Use Git Bash only and click next
  • Configuring the line ending conversions: check Checkout Windows-style, commit Unix-style line endings and click next
  • Completing the Git Setup Wizard: uncheck View ReleaseNotes.rtf and click finish

Configure msysgit

Java SDK

Install the latest Java SDK 1.6, http://www.oracle.com/technetwork/java/javase/downloads/jdk-6u31-download-1501634.html. As I understand it Android SDK is built on 1.6, so 1.7 will not work for Android.

Maven

Download Maven, http://maven.apache.org/download.html. I choosed apache-maven-3.0.4-bin.zip.

The installation instructions are further down the same page.

  1. Unzip the distribution archive, i.e. apache-maven-3.0.4-bin.zip to the directory you wish to install Maven 3.0.4. These instructions assume you chose C:\Program Files\Apache Software Foundation. The subdirectory apache-maven-3.0.4 will be created from the archive.
  2. Add the M2_HOME environment variable by opening up the system properties (WinKey + Pause), selecting the “Advanced” tab, and the “Environment Variables” button, then adding the M2_HOME variable in the user variables with the value C:\Program Files\Apache Software Foundation\apache-maven-3.0.4. Be sure to omit any quotation marks around the path even if it contains spaces. Note: For Maven < 2.0.9, also be sure that the M2_HOME doesn’t have a ‘\’ as last character.
  3. In the same dialog, add the M2 environment variable in the user variables with the value %M2_HOME%\bin.
  4. Optional: In the same dialog, add the MAVEN_OPTS environment variable in the user variables to specify JVM properties, e.g. the value -Xms256m -Xmx512m. This environment variable can be used to supply extra options to Maven.
  5. In the same dialog, update/create the Path environment variable in the user variables and prepend the value %M2% to add Maven available in the command line.
  6. In the same dialog, make sure that JAVA_HOME exists in your user variables or in the system variables and it is set to the location of your JDK, e.g. C:\Program Files\Java\jdk1.5.0_02 and that %JAVA_HOME%\bin is in your Path environment variable.
  7. Open a new command prompt (Winkey + R then type cmd) and run mvn --version to verify that it is correctly installed.

Android SDK

Download Android SDK, http://developer.android.com/sdk/index.html. I choosed installer_r16-windows.exe.

  • Run the installer
    • Welcome to the Android SDK Tools Setup Wizard: click next
    • Java SE Development Kit: click next
    • Choose Install Location: leave default and click next
    • Choose Start Menu Folder: leave default and click Install
    • Installation Complete: click next
    • Completing the Android SDK Tools Setup Wizard: leave Start SDK Manager checked and click Finish
  • The Android SDK Manager Starts. Check the following:
    • Tools
      • Android SDK Tools (if not already installed)
      • Android SDK Platform-tools
    • Android 4.0.3 (API 15)
      • SDK Platform
      • ARM EABI v7a System Image (the Android emulator)
      • Google APIs by Google Inc.
      • Sources for Android SDK
    • Extras
      • Google USB Driver package
  • Click Install X packages
  • Check Accept All and click Install

Android Maven Plugin

The project: http://code.google.com/p/maven-android-plugin/. Renamed from maven-android-plugin to android-maven-plugin.
Configuration:

  • Add an environment variable (system variable) with the name “ANDROID_HOME” and the value “C:\Program Files\Android\android-sdk”.
  • Add the following to the end of the “Path” variable: “;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools”

The rest is handled by configurating the pom files in your android projects.

Maven Android SDK Deployer

The Maven Android SDK Deployer is a helper maven project that can be used to install the libraries necessary to build Android applications with Maven and the Android Maven Plugin directly from your local Android SDK installation, https://github.com/mosabua/maven-android-sdk-deployer. Some Android add-ons are not available at the maven-repository. This tool helps you copy the *.jar files to your users local repository (~/.m2/repository/android and ~/.m2/repository/com/google/android/maps and ) and you can therefore use the following dependencies in your project. When using “Robolectric” for unit testing the android app you get warnings about making shadows of types in the maps.jar for example. Download the project and run the command:
mvn install
in the root folder of the project. Help: https://github.com/mosabua/maven-android-sdk-deployer#readme.

IntelliJ IDEA

Download and install the IntelliJ IDEA 11 Community Edition (Free), http://www.jetbrains.com/idea/download/index.html.

Robolectric

Information: http://pivotal.github.com/robolectric
Source: https://github.com/xtremelabs/robolectric

Advertisements
Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: