Apache Maven is an innovative software tool used to build and manage projects. Based on Project Object Model (POM), Maven can manage everything from a project’s build, reporting and documentation – all from a central piece of information.
Using the Maven tool to build Android applications is still a new concept that’s not widely adopted by the Android App Development community. Instead, the preferred development tool for Androids is Eclipse IDE, which also provides the opportunity to build related functionality. Despite its unpopularity, there are still a hand full of developers who use Maven to manage projects and resolve all build related complications.
When building an Android application, generating application packages (.apk) can present complications in terms of Maven project setup, configuration and ensuring its operational. Some of the challenges include launching Emulator, creating an .apk file and installing the application on an Android device.
Below are steps and recommendations to configure Maven to build an Android application.
1. Download and install JDK 1.6 or 1.7
2. Download and install Maven 3.1.1+
3. Install ANDROID SDK
Note: It is important to remember the Android SDK download location. In this tutorial, we are considering it as C:\Android\android-sdk
4. Setup JDK, Android SDK and Maven environment variable:
SET PATH (environment path variable):
Note: Try system environment variable if user variable is not reflecting.
Build and Verification
To verify Maven build setup, we will proceed with sample Android project. Download a sample Maven Android Project.
After successfully downloading and extracting archive file, navigate to the directory below:
Open command prompt and navigate to helloflashlight directory and test maven command
Generating final build Application package (.apk)
Once BUILD SUCCESS, verify the final application build file in the target folder
To setup a successful Android Maven project, understanding of POM.xml file is very important. Once the build is successful, make sure you visit pom.xml file and verify the Android dependency. Here are some key Android related dependency mentioned in pom.xml
Let us know what you think – are there other tools that you use to build Android Apps with? If so, let us know your best practices in the comments section below.