Using Ant with Android and IntelliJ
Sep
17
Written by:
9/17/2011 1:02 PM
As some may be aware, I have been putting some of my efforts towards becoming an android developer. As a .Net developer, I absolutely
loathe Eclipse, which is the Google preferred IDE. The good folks at
JetBrains have updated their
IntelliJ IDEA IDE about a year ago to work natively with the Android SDK. As a .Net developer, this is awesome!
Anyway, one of the struggles I have had is getting my Android APK to use the proguard configuration from IntelliJ, which kind of isn't good since it's use is recommended prior to deploying an application. Well... today I figured out how to make this whole thing work.
Step 1: Update
local.properties
My build script kept failing because the SDK path was wrong. I use Linux as my principal Android developer machine, and the path in local.properties was incorrect. It was basically missing an x in the path, but once I updated it, it worked like a charm.
Previous Setting: sdk.dir=/home/scott/android-sdk-linux_86
New Setting: sdk.dir=/home/scott/android-sdk-linux_
x86
Step 2: Install Ant
This threw me for a loop since IntelliJ IDEA has tight integration with Ant. I use Linux Mint, so a quick
sudo apt-get install ant
fixed that issue.
Step 3: Run Ant
From my command line, I needed to run ant. To do so, make sure you're in your project directory, then type in
ant release
This will cause ant to build a release version of your APK. Hooray!
Side note, if you want to enable automatic signing as part of your build process, you can do that. In your
build.properties file, add two lines:
key.store=
key.alias=
During your build, you will be prompted for a password for your Key store and alias. If you mess either up, it will fail during compilation.
Hope this helps!