问题描述
||
我实际上是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>
可能是因为最后一行中指定的网址可能不同吗?
任何想法为什么会发生这种情况?
任何答复都受到高度赞赏。在此先多谢!!
解决方法
您已经安装了适用于Java项目(和.jar文件)的\“ normal \” Maven插件。
对于Android,您需要Maven Android插件
我个人认为,对于我在项目中使用的少数依赖项,Android Maven太麻烦了,但这是我在尝试时进行设置的方式:
将ANDROID_HOME变量设置为您的SDK根目录,并将SDK的
tools
和platform-tools
文件夹添加到您的路径中(更多信息请参见此链接)
启动Eclipse并在您的Android项目上启用\“ Dependency management \”。
确保将Maven Central包括在存储库中,并将以下内容添加到pom中(更多信息,请参见此链接或此链接)。
<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版本。
, 最近更新:工件的名称现在是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>