Error in pom file in Maven project after importing into Eclipse
Asked Answered
M

2

13

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

Moneychanger answered 23/6, 2011 at 10:43 Comment(0)
M
10

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.

Mackle answered 23/6, 2011 at 11:42 Comment(2)
Hi,I am not able to download the Maven Android plugin.I have been trying since yesterday.Any idea from where I can do this??And how do I set it up for use??Moneychanger
Check my revised answer on how to set it up. I just tried to install the plugin myself and was able to download the plugin successfully from the Eclipse Marketplace. What is going wrong? Any error messages?Mackle
O
1

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>
Okinawa answered 9/8, 2013 at 15:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.