Saturday, May 25, 2013

Sample Android App Maven Pom for Eclipse ADT Bundle


I've learned it's best to download the ADT bundle rather than try to add the ADT plugin to an existing eclipse install. 

http://developer.android.com/sdk/index.html

This version seems to have good performance on mac too.

Android Developer Tools
Build: v22.0.0-675183

Just create a sample Android application using the usual eclipse menus. 
Then convert to maven use m2e-android

then edit with the following to get it to work at the command line. 

Then update project settings from the maven context menu. 

you can now deploy to emulator and usb with the following command lines. 

mvn clean install android:redeploy -Dandroid.device=emulator android:run -X -Dandroid.ndk.path=/opt/local/share/java/android-ndk-macosx -Dandroid.sdk.path=/opt/local/share/java/android-sdk-macosx/

mvn clean install android:redeploy -Dandroid.device=usb android:run -X -Dandroid.ndk.path=/opt/local/share/java/android-ndk-macosx -Dandroid.sdk.path=/opt/local/share/java/android-sdk-macosx/


or run as Android Application in the usual way in eclipse. 


<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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>SupportAppNavigation</groupId>
  <artifactId>SupportAppNavigation</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>apk</packaging>
  <properties>
    <platform.version>4.1.1.4</platform.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>com.google.android</groupId>
      <artifactId>android</artifactId>
      <version>${platform.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.google.android</groupId>
      <artifactId>annotations</artifactId>
      <version>${platform.version}</version>
    </dependency>
    <dependency>
      <groupId>com.google.android</groupId>
      <artifactId>support-v4</artifactId>
      <version>r7</version>
    </dependency>
    <dependency>
      <groupId>commons-io</groupId>
      <artifactId>commons-io</artifactId>
      <version>2.1</version>
    </dependency>
  </dependencies>

  <build>
    <finalName>${project.artifactId}</finalName>
    <sourceDirectory>src</sourceDirectory>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>com.jayway.maven.plugins.android.generation2</groupId>
          <artifactId>android-maven-plugin</artifactId>
          <version>3.6.0</version>
          <extensions>true</extensions>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.2</version>
        <configuration>
          <source>1.6</source>
          <target>1.6</target>
        </configuration>
      </plugin>
      <plugin>
        <groupId>com.jayway.maven.plugins.android.generation2</groupId>
        <artifactId>android-maven-plugin</artifactId>
        <version>3.6.0</version>
        <configuration>
          <androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile>
          <assetsDirectory>${project.basedir}/target/assets</assetsDirectory>
          <classifier>${classifier}</classifier>
          <resourceDirectory>${project.basedir}/res</resourceDirectory>
          <nativeLibrariesDirectory>${project.basedir}/src/main/native</nativeLibrariesDirectory>
          <sdk>
            <platform>17</platform>
          </sdk>
          <sign>
            <debug>true</debug>
          </sign>
          <undeployBeforeDeploy>true</undeployBeforeDeploy>
        </configuration>
        <extensions>true</extensions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>2.5.1</version>
      </plugin>
    </plugins>


  </build>

</project>

1 comment:

  1. BUT Maven is not installed with ADT Bundle!!! How to add it after ADT Bundle is installed?.

    ReplyDelete