我想在maven中使用一个简单的android hello world程序。这是我的pom.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>appzoyfoo141</groupId>
<artifactId>ekanta</artifactId>
<version>1.0.0</version>
<packaging>apk</packaging>
<name>ekanta</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<platform.version>4.1.1.4</platform.version>
<android.plugin.version>3.1.1</android.plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.1.1.4</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>${android.plugin.version}</version>
<extensions>true</extensions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<configuration>
<sdk>
<platform>17</platform>
<path>${ANDROID_HOME}</path>
</sdk>
</configuration>
</plugin>
</plugins>
</build>
</project>
但是在尝试运行pom.xml时右键单击pom.xml-&gt; runas-&gt; maven test..getting此错误
Failed to execute goal com.jayway.maven.plugins.android.generation2`..Can anybody plz help me..thanks i am getting this error in console`[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.613s
[INFO] Finished at: Thu Jan 09 14:47:46 IST 2014
[INFO] Final Memory: 6M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.1.1:generate-sources (default-generate-sources) on project ekanta: No Android SDK path could be found. You may configure it in the plugin configuration section in the pom file using <sdk><path>...</path></sdk> or <properties><android.sdk.path>...</android.sdk.path></properties> or on command-line using -Dandroid.sdk.path=... or by setting environment variable ANDROID_HOME -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException`
答案 0 :(得分:1)
在尝试构建Android Bootstrap项目时,我遇到了与com.jayway.maven插件相同的问题。
我可以通过进入pom.xml属性部分并添加我的ANDROID sdk路径来解决这个问题。
<properties>
<abs.version>4.3.1</abs.version>
<dagger.version>1.0.1</dagger.version>
<otto.version>1.3.4</otto.version>
<gson.version>2.2.4</gson.version>
<menudrawer.version>3.0.2</menudrawer.version>
<android.sdk.path>C:\Android\adt-bundle-windows-x86_64-20131030\sdk</android.sdk.path>
</properties>
我最初指向我的JAVA SDK导致它失败 - 你需要将它指向你的ANDROID sdk。
答案 1 :(得分:-1)
未设置此路径:ANDROID_HOME
您的SDK可能版本太低。然后在setting.xml之后设置完整路径android sdk。