Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error in pom file in Maven project after importing into Eclipse

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

like image 358
dipti Avatar asked Jun 23 '11 10:06

dipti


2 Answers

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.

like image 137
THelper Avatar answered Oct 21 '22 09:10

THelper


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>
like image 28
user2371392 Avatar answered Oct 21 '22 07:10

user2371392