|Maven: The Complete Reference
- 14.2. Configuring Build Environment for Android Development
Before you attempt to build your Android libraries and applications with Maven, you will need to install the Android SDK and potentially install the Android API jar files into your local Maven repository or your repository server.
The Android Maven Plugin requires the presence of the Android SDK in your development environment. Install the SDK following the directions on the Android Developer web site.
on a Unix/bash based system or
on a Windows system.
In addition to the SDK, the various platform versions you need for development should also be installed following the instructions. You can install a subset of available platforms or simply install all available versions.
Optionally, the path
When building an Android application with Maven the compile process needs access to the Android API for the specific platform version the project is configured against. The Android SDK ships this as android.jar files in the different platform folders. In order for Maven to access these libraries, they need to be available in the local Maven repository.
Typically artifacts are available in Maven Central, however only the platform versions available in the Android Open Source Project are published to Maven Central. Newer versions of the platform as well as the compatibility package and proprietary extensions like the Google Maps support are not available there and need to be published to your Maven repository, if you want to use them in your Android project.
The artifacts published to Maven central are available as dependencies
under the groupId
The Maven Android SDK Deployer has been created to publish artifacts from the Android SDK into your local repository or repository server when using components that are not available in Central.
Download the tool by clicking on the
In order to install the android jar files from the different platform revisions into your local repository you run the command in the deployer folder.
cd mosabua-maven-android-sdk-deployer-df824df mvn clean install
By default this will install all android.jar, maps.jar, usb.jar files
and the compatibilty packages into your local Maven repository. You
should find all newly installed files in the
The above deployment works fine for one machine, but if you need to supply a whole team of developers and a cluster of build machines with the artifacts, you will want to deploy the artifacts once to a remote repository server that is available to all users. If you are not currently using a repository manager, you should download Nexus and configure a user with permission to deploy artifacts to a repository. To get started with Nexus, read the Nexus Installation chapter in the free, online Nexus book.
As a first step you will need to edit the
Then you need to add a server with the correct access credentials for the server to your Maven Settings file.
Snippet for settings.xml for the repository server access credentials.
<settings> <servers> <server> <id>android.repo</id> <username>your username</username> <password>your password</password> </server> </servers> </settings>
Once that configuration is completed, you can deploy the artifacts with
By default the Maven Android SDK Deployer tool will attempt to install or deploy all versions of the platforms artifacts into a repository. If you decide to only install a subset of the components the tool can be used with profile options to only install or deploy some artifacts. This can be done by specifying the platform API versions as a profile name.
mvn install -P 3.2
Further details are available in the Maven Android SDK Deployer documentation.