I use the maven-android-plugin
version 3.3.2. When I try to build my android project I have the following exception:
我使用的是maven-android-plugin version 3.3.2。当我尝试构建我的android项目时,我有以下的例外:
org.apache.maven.plugin.MojoExecutionException
: 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 variableANDROID_HOME
org.apache.maven.plugin。MojoExecutionException:无法找到Android SDK路径。您可以在pom文件的插件配置部分使用
…< /路径> < / sdk >或 <属性> < android.sdk.path > < / android.sdk。路径> 或使用-Dandroid.sdk.path=…或者通过设置环境变量ANDROID_HOME
However environment variable ANDROID_HOME
is set to android sdk path.
但是环境变量ANDROID_HOME被设置为android sdk路径。
Can you please help me?
你能帮我一下吗?
4 个解决方案
#1
25
It sounds like, while the env var is available on the shell you run, it isn't available on the shell Maven runs.
虽然env var在您运行的shell上是可用的,但是在shell Maven运行上却不可用。
Regardless, instead of working around it, it's best to create a settings file with the property set. A minimal one would look like this (writing off the top of my head, as I don't have my settings file available now) :
无论如何,与其使用它,不如创建一个带有属性集的设置文件。
<settings>
<profiles>
<profile>
<id>android-settings</id>
<properties>
<android.sdk.path>/path/to/android/sdk</android.sdk.path>
</properties>
</profile>
</profiles>
<activeProfiles>
<activeProfile>android-settings</activeProfile>
</activeProfiles>
</settings>
Throw it into your .m2
folder or set it via Eclipse in Window
->Preferences...
->Maven
->User Settings
.
将它放入.m2文件夹中,或者通过Eclipse在窗口->首选项中设置它……- > Maven - >用户设置。
#2
4
From the documentation
从文档
You may configure it in the android-maven-plugin
configuration section in the pom.xml
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
.
您可以在pom中的android-maven-plugin配置部分配置它。xml文件使用< sdk > <路径> …< /路径> < / sdk >或 <属性> < android.sdk.path > < / android.sdk。路径> 或使用-Dandroid.sdk.path=…或者通过设置环境变量ANDROID_HOME。
Solution 1
解决方案1
I have defined an Android SDK system variable called ANDROID_SDK
(instead of ANDROID_HOME
) and referenced it in my pom.xml
this way:
我已经定义了一个名为ANDROID_SDK(而不是ANDROID_HOME)的Android SDK系统变量,并在pom中引用了它。xml:
<groupId>...</groupId>
<artifactId>...</artifactId>
<version>...</version>
<packaging>apk</packaging>
<name>...</name>
<description>...</description>
<properties>
<android.sdk.path>${env.ANDROID_SDK}</android.sdk.path>
...
</properties>
Solution 2
解决方案2
As an alternative you can also configure it in the android-maven-plugin
section:
另外,你也可以在android-maven-plugin部分对其进行配置:
<plugin>
<extensions>true</extensions>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>${android-maven-plugin.version}</version>
<configuration>
<androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile>
<assetsDirectory>${project.basedir}/assets</assetsDirectory>
<resourceDirectory>${project.basedir}/res</resourceDirectory>
<nativeLibrariesDirectory>${project.basedir}/src/main/native</nativeLibrariesDirectory>
<sdk>
<android.sdk.path>${env.ANDROID_SDK}</android.sdk.path>
<platform>16</platform>
</sdk>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
</plugin>
Solution 3
解决方案3
As a third option you can set the SDK from the command line passing an argument to Maven:
作为第三个选项,您可以从命令行设置SDK,将参数传递给Maven:
mvn clean install -Dandroid.sdk.path="C:\\Program Files (x86)\\Android\\android-sdk"
mvn -Dandroid.sdk干净安装。路径= " C:\ \ Android程序文件(x86)\ \ \ \ Android sdk”
#3
2
Yes i solved this issue.By adding settings.xml file in ~/.m2 folder
是的,我解决了这个问题。通过添加设置。在~ / xml文件。m2文件夹
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<profiles>
<profile>
<id>android</id>
<properties>
<android.sdk.path>
ANDROID SDK PATH
</android.sdk.path>
</properties>
</profile>
</profiles>
<activeProfiles> <!--make the profile active all the time -->
<activeProfile>android</activeProfile>
</activeProfiles>
</settings>
and open your android-bootstrap-master app and open pom.xml file and check the following line
打开android-bootstrap-master应用,打开pom。xml文件并检查以下行
<sdk>
<platform>16</platform>
</sdk>
16 is the currently installed or not sdk level
16是当前安装的或不安装的sdk级别
#4
1
The easiest way is to set export ANDROID_HOME=pathToAndroidSdk
right from the target deploy repository.
最简单的方法是从目标部署存储库中设置export ANDROID_HOME=pathToAndroidSdk。
Variable will be set only for current shell and all processes started from current shell.
变量将只设置为当前shell,所有进程从当前shell开始。
#1
25
It sounds like, while the env var is available on the shell you run, it isn't available on the shell Maven runs.
虽然env var在您运行的shell上是可用的,但是在shell Maven运行上却不可用。
Regardless, instead of working around it, it's best to create a settings file with the property set. A minimal one would look like this (writing off the top of my head, as I don't have my settings file available now) :
无论如何,与其使用它,不如创建一个带有属性集的设置文件。
<settings>
<profiles>
<profile>
<id>android-settings</id>
<properties>
<android.sdk.path>/path/to/android/sdk</android.sdk.path>
</properties>
</profile>
</profiles>
<activeProfiles>
<activeProfile>android-settings</activeProfile>
</activeProfiles>
</settings>
Throw it into your .m2
folder or set it via Eclipse in Window
->Preferences...
->Maven
->User Settings
.
将它放入.m2文件夹中,或者通过Eclipse在窗口->首选项中设置它……- > Maven - >用户设置。
#2
4
From the documentation
从文档
You may configure it in the android-maven-plugin
configuration section in the pom.xml
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
.
您可以在pom中的android-maven-plugin配置部分配置它。xml文件使用< sdk > <路径> …< /路径> < / sdk >或 <属性> < android.sdk.path > < / android.sdk。路径> 或使用-Dandroid.sdk.path=…或者通过设置环境变量ANDROID_HOME。
Solution 1
解决方案1
I have defined an Android SDK system variable called ANDROID_SDK
(instead of ANDROID_HOME
) and referenced it in my pom.xml
this way:
我已经定义了一个名为ANDROID_SDK(而不是ANDROID_HOME)的Android SDK系统变量,并在pom中引用了它。xml:
<groupId>...</groupId>
<artifactId>...</artifactId>
<version>...</version>
<packaging>apk</packaging>
<name>...</name>
<description>...</description>
<properties>
<android.sdk.path>${env.ANDROID_SDK}</android.sdk.path>
...
</properties>
Solution 2
解决方案2
As an alternative you can also configure it in the android-maven-plugin
section:
另外,你也可以在android-maven-plugin部分对其进行配置:
<plugin>
<extensions>true</extensions>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>${android-maven-plugin.version}</version>
<configuration>
<androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile>
<assetsDirectory>${project.basedir}/assets</assetsDirectory>
<resourceDirectory>${project.basedir}/res</resourceDirectory>
<nativeLibrariesDirectory>${project.basedir}/src/main/native</nativeLibrariesDirectory>
<sdk>
<android.sdk.path>${env.ANDROID_SDK}</android.sdk.path>
<platform>16</platform>
</sdk>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
</plugin>
Solution 3
解决方案3
As a third option you can set the SDK from the command line passing an argument to Maven:
作为第三个选项,您可以从命令行设置SDK,将参数传递给Maven:
mvn clean install -Dandroid.sdk.path="C:\\Program Files (x86)\\Android\\android-sdk"
mvn -Dandroid.sdk干净安装。路径= " C:\ \ Android程序文件(x86)\ \ \ \ Android sdk”
#3
2
Yes i solved this issue.By adding settings.xml file in ~/.m2 folder
是的,我解决了这个问题。通过添加设置。在~ / xml文件。m2文件夹
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<profiles>
<profile>
<id>android</id>
<properties>
<android.sdk.path>
ANDROID SDK PATH
</android.sdk.path>
</properties>
</profile>
</profiles>
<activeProfiles> <!--make the profile active all the time -->
<activeProfile>android</activeProfile>
</activeProfiles>
</settings>
and open your android-bootstrap-master app and open pom.xml file and check the following line
打开android-bootstrap-master应用,打开pom。xml文件并检查以下行
<sdk>
<platform>16</platform>
</sdk>
16 is the currently installed or not sdk level
16是当前安装的或不安装的sdk级别
#4
1
The easiest way is to set export ANDROID_HOME=pathToAndroidSdk
right from the target deploy repository.
最简单的方法是从目标部署存储库中设置export ANDROID_HOME=pathToAndroidSdk。
Variable will be set only for current shell and all processes started from current shell.
变量将只设置为当前shell,所有进程从当前shell开始。