Published on May 10, 2011 by Toran Billups
I recently started playing around with Android and found it difficult to get my development environment setup. I suppose this is something I should have expected given it's the java ecosystem, but my recent fling with objective-c had me thinking back to the 'good old days' when you just opened the editor and hit go.
Most of the examples I found online would show you how to get started with Android using Eclipse but as I'm already using Intellij at work I thought this would be a great opportunity to learn the shortcuts and editor in depth. So off I went to download a free copy of the community edition.
After a few days of trial and error I got to talking with a co-worker about how he got setup doing Android development and he mentioned Maven. I was using Maven at work as a build/dependency management tool of sorts but as I'm new to the java world I didn't know much about it. I had him walk me through a basic setup and thought why not share that with others who might be interested in Android development.
I also thought this would be valuable because most blog posts/tutorials online kept the focus on Intellij (w/out Maven) or Eclipse. It was rare to come across a 'how-to' that mentioned Android, Intellij and Maven.
So I started documenting the steps required to get a perfect build up and running on a freshly formatted Windows 7 machine. But instead of displaying a bunch of steps in text format I decided to do a short (23ish minutes) screencast that I recorded on a freshly formatted machine. The video was taken on my netbook so I didn't launch the emulator (not enough power) but I did detail each step required to get a new Android developer up and running.
If you don't feel like watching the video here are the basic steps in less detail
1.) Install the JDK
2.) Add the JAVA_HOME env variable
3.) Install the Android SDK
4.) Add the ANDROID_HOME env variable
5.) Add platform tools to your class path (to call adb later)
6.) Install Maven
7.) Add Maven to your class path
8.) Add the M2_HOME env variable
9.) Install Intellij
10.) Open a command prompt and type the following command to generate your mvn project
mvn archetype:generate -DarchetypeArtifactId=android-quickstart -DarchetypeGroupId=de.akquinet.android.archetypes -DarchetypeVersion=1.0.5 -DgroupId=com.somepkg.android -DartifactId=SomeProjectName
11.) cd into the project directory you just created and do an mci w/out testing included
mvn clean install -Dtest=false -DfailIfNoTests=false
12.) Open Intellij
13.) Open your project and do a build (control + F9) - this should fail
14.) Add the JDK to your Intellij project
15.) Go back to the command prompt and do a 'mvn clean install'
16.) Start the emulator
17.) Go back to the command prompt and enter the following to push your apk to the emulator
adb install target/*.apk (where *.apk is the apk you want pushed to the emulator)
I hope this helps someone else get started with Android!