Error in pom file in Maven project after importing into Eclipse

dipti picture dipti · Jun 23, 2011 · Viewed 15.4k times · Source

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!!

Answer

THelper picture THelper · Jun 23, 2011

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.