我实际上是 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不一样? 为什么会发生这种情况的任何想法? 非常感谢任何回复。非常感谢!!
最佳答案
您已经安装了适用于 Java 项目(和 .jar 文件)的“普通”Maven 插件。 对于 Android,您需要 Maven Android Plugin
就我个人而言,我认为 Android Maven 对于我在项目中使用的几个依赖项来说太麻烦了,但我在尝试时是这样设置的:
将 ANDROID_HOME 变量设置为您的 SDK 根位置,并将 SDK 的
tools
和platform-tools
文件夹添加到您的路径(更多信息请参见 this link)启动 Eclipse 并在您的 Android 项目上启用“依赖关系管理”。
确保包含 Maven Central添加到您的存储库并将以下内容添加到您的 pom(更多信息请参见 this link 或 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>
当然你可以根据自己的喜好调整安卓版本。
关于android - Maven项目导入Eclipse后pom文件报错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6452754/