How to integrate Android Development Tools and Maven

With the Maven Android Plugin it is possible to build and deploy/undeploy your android app and start/stop the emulator – if you’re used to maven you won’t be going without it ;) If you’re interested in signing your apk using maven – take a look at this article Project Setup Create an android project using the android tool We need some dependencies – so create a pom.xml in the project’s root directory – I took this from the plugin samples and modified it: <?xml version="1.0" encoding="UTF-8"?> <!-- Copyright (C) 2009 Jayway AB Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.hascode.android.app</groupId> <artifactId>demo</artifactId> <packaging>apk</packaging> <name>hasCode.com - Sample Android App using the Maven Android Plugin</name> <version>0.1</version> <dependencies> <dependency> <groupId>android</groupId> <artifactId>android</artifactId> <version>2.1</version> <scope>provided</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.8.1</version> <scope>test</scope> </dependency> </dependencies> <build> <!--<finalName>${artifactId}</finalName>--> <plugins> <plugin> <groupId>com.jayway.maven.plugins.android.generation2</groupId> <artifactId>maven-android-plugin</artifactId> <configuration> <sdk> <path>${env.ANDROID_HOME}</path> <platform>3</platform> </sdk> <deleteConflictingFiles>true</deleteConflictingFiles> </configuration> <extensions>true</extensions> </plugin> <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.5</source> <target>1.5</target> </configuration> </plugin> </plugins> </build> </project> ...

April 2, 2010 · 3 min · 453 words · Micha Kops