【问题标题】:Error in pom file in Maven project after importing into Eclipse导入到 Eclipse 后,Maven 项目中的 pom 文件出错
【发布时间】:2011-06-23 10:43:13
【问题描述】:

我实际上是 Maven 框架的新手。我已经有一个 Maven 项目。我从http://m2eclipse.sonatype.org/sites/m2e 将 Maven 插件等安装到了我的 EclipseIDE 中。然后我导入了我的项目并启用了依赖项,但是该项目显示了太多错误。 pom.xml 本身显示错误。错误是

Project Build Error:unknown packaging:apk
Project Build Error:unresolvable build extension:plugin" 

等等

我的错误区域是:

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>

可能是因为最后一行中指定的 url 可能不同? 任何想法为什么会发生这种情况? 任何回复都非常感谢。提前非常感谢!

【问题讨论】:

    标签: android maven-plugin m2eclipse android-maven-plugin


    【解决方案1】:

    您已经安装了适用于 Java 项目(和 .jar 文件)的“普通”Maven 插件。 对于 Android,您需要 Maven Android Plugin

    就我个人而言,我认为 Android Maven 对于我在项目中使用的少数依赖项来说太麻烦了,但我在试用时是这样设置的:

    • 将 ANDROID_HOME 变量设置为您的 SDK 根位置,并将 SDK 的 toolsplatform-tools 文件夹添加到您的路径(更多信息请参阅 this link

    • 启动 Eclipse 并在您的 Android 项目上启用“依赖管理”。

    • 确保将Maven Central 包含到您的存储库中,并将以下内容添加到您的pom 中(更多信息请参见this linkthis 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>
    

    当然你可以根据自己的喜好调整安卓版本。

    【讨论】:

    • 嗨,我无法下载 Maven Android 插件。我从昨天开始一直在尝试。有什么想法可以从哪里做到这一点??我该如何设置它以供使用??
    • 查看我修改后的答案,了解如何设置它。我只是尝试自己安装插件,并且能够从 Eclipse Marketplace 成功下载插件。出了什么问题?有任何错误信息吗?
    【解决方案2】:

    最后更新:现在神器的名字好像是android-maven-plugin:http://mvnrepository.com/artifact/com.jayway.maven.plugins.android.generation2/android-maven-plugin/3.6.0

    所以应该是这样的:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多