I am actually new to the Maven framework. I already have a Maven project. I installed the Maven plugin etc into my EclipseIDE from http://m2eclipse.sonatype.org/sites/m2e. Then I imported my project and enabled dependencies, but the project is showing too many errors. The pom.xml itself is showing errors. The errors are
Project Build Error:unknown packaging:apk
Project Build Error:unresolvable build extension:plugin"
etc.
My error area is:
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>com.nbc.cnbc.android</groupId>
<artifactId>android.domain.tests</artifactId>
<version>1.0.0</version>
<packaging>apk</packaging>
<parent>
<groupId>com.nbc.cnbc.android</groupId>
<artifactId>android.domain.parent</artifactId>
<version>1.0.0</version>
<relativePath>../android.domain.parent/pom.xml</relativePath>
</parent>
<name>android.domain.tests</name>
<url>http://maven.apache.org</url>
Could it be because the url specified in the last line could be different? Any ideas why this could be happening? Any reply is highly appreciated. Thanks a lot in advance!!
You have installed the "normal" Maven plugin that works for Java projects (and .jar files). For Android you need the Maven Android Plugin
Personally, I think that Android Maven is too much of a hassle for the few dependencies that I use in my projects, but this is how I set it up when I tried it out:
Set the ANDROID_HOME variable to your SDK root location and add the SDK's tools
and platform-tools
folders to your path (more info see this link)
Start Eclipse and enable "Dependency management" on your Android project.
Make sure you include Maven Central to you repositories and add the following to your pom (more info see this link or this link).
<dependency> <groupId>com.google.android</groupId> <artifactId>android</artifactId> <version>2.3.3</version> <scope>provided</scope> </dependency> <build> <sourceDirectory>src</sourceDirectory> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> <plugin> <groupId>com.jayway.maven.plugins.android.generation2</groupId> <artifactId>maven-android-plugin</artifactId> <configuration> <sdk> <path>${env.ANDROID_HOME}</path> <platform>10</platform> </sdk> <deleteConflictingFiles>true</deleteConflictingFiles> </configuration> <extensions>true</extensions> </plugin> </plugins> </build>
Off course you can adjust the android version to your liking.
Last update: it seems that the name of the artifact is android-maven-plugin now: http://mvnrepository.com/artifact/com.jayway.maven.plugins.android.generation2/android-maven-plugin/3.6.0
So it should be like this:
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>2.3.3</version>
<scope>provided</scope>
</dependency>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<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>
<configuration>
<sdk>
<path>${env.ANDROID_HOME}</path>
<platform>10</platform>
</sdk>
<deleteConflictingFiles>true</deleteConflictingFiles>
</configuration>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With