huangp@vm:~$

All geeky stuff

set up Android development with maven and intellij

Download android SDK and unpack it to a location (mine is ~/tools/android-sdk-linux_x86).
Set up android home environment variable. Alternatively you may consider to have an environment variable setup file to better manage all these. See this post.

export ANDROID_SDK_HOME=$HOME/tools/android-sdk-linux_x86

Set up andriod SDK

cd $ANDROID_SDK_HOME
./android

In the GUI click on Available Packages and select all the packages you want.
Click Virtual Devices and create a new android virtual device. Better name it something indicating its target android version(i.e. avd2.3.3). Adjust other settings as you wish.

Bare minimal android SDK is all done now. Next move onto maven. There is an excellent blog for all the details from the archetype author here. The simplest step will be (assuming you already have maven set up and you also prefer to have test with all your code):

mvn archetype:generate \
-DarchetypeArtifactId=android-quickstart \
-DarchetypeGroupId=de.akquinet.android.archetypes \
-DarchetypeVersion=1.0.4 \
-DgroupId=your.company \
-DartifactId=my-android-application

Watch it finishes and now you can use intellij to open the pom.xml file.
Open your Project Structrue (ctrl+alt+shift+s), select Platform Settings->SDKs and create a new Android SDK by browsing to your installed location. Back to your Project Settings->Modules, click Dependencies tab and flip Module SDK to android.

Open your android activity file (if you use the archetype then the default created one is HelloAndroidActivity.java. ctrl+shift+F10 to run it. You should see a virtual device launched and your dummy application is deployed on it. Hooray!

Note: by default it will launch the first virtual device you created. But if you have more than one and want to run your application on a different one, you can choose it from the run configurations menu.

Leave a comment