Maven项目导入Eclipse后pom文件出错

发布于 2024-11-16 16:57:37 字数 1296 浏览 5 评论 0原文

我实际上是 Maven 框架的新手。我已经有一个 Maven 项目了。我从 http://m2eclipse.sonatype.org/sites/m2e。然后我导入了我的项目并启用了依赖项,但该项目显示了太多错误。 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 可能不同? 有什么想法为什么会发生这种情况吗? 任何回复都将受到高度赞赏。非常感谢!

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

千仐 2024-11-23 16:57:37

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

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

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

  • 启动 Eclipse 并启用“依赖项” 启动 Eclipse 并在 Android项目

  • 确保将 Maven Central 添加到您的存储库中并添加以下内容到你的pom(更多信息请参阅此链接此链接)。

<依赖>;
  com.google.android;
  android;
  <版本>2.3.3
  <范围>提供


<构建>
   src
   <插件>
       <插件>
           org.apache.maven.plugins
           maven-compiler-plugin;
           <配置>
               <来源>1.6
               <目标>1.6
           
       
       <插件>
           com.jayway.maven.plugins.android. Generation2
           maven-android-plugin;
           <配置>
               
                  <路径>${env.ANDROID_HOME}
                   <平台>10
               
               true;
           
           <扩展名> true
       
   

当然,您可以根据自己的喜好调整 Android 版本。

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.

浅忆 2024-11-23 16:57:37

最后更新:现在工件的名称似乎是 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>

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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文