gpt4 book ai didi

android - 无法让 android-maven-plugin 识别 SDK 路径

转载 作者:太空狗 更新时间:2023-10-29 14:16:35 24 4
gpt4 key购买 nike

在尝试使用 android-maven-plugin 构建 Android 应用程序时,我尝试了所有宣传的方法来指定我的 Android SDK 的路径,但没有任何效果。无论我做什么,当我运行时

mvn clean install

我明白了

... Could not find tool 'aapt'. Please provide a proper Android SDK directory path as configuration parameter <sdk><path>...</path></sdk> in the plugin <configuration/>. As an alternative, you may add the parameter to commandline: -Dandroid.sdk.path=... or set environment variable ANDROID_HOME.

我将环境变量ANDROID_HOME设置为指向SDK的根目录,并将其导出。然后

<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
...
<configuration>
<sdk>
<path>${env.ANDROID_HOME}</path>
<platform>19</platform>
</sdk>
...
</configuration>
</plugin>

不起作用。 (我在 SDK 中安装了 API 19)

<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
...
<configuration>
<sdk>
<path>/absolute/path/to/sdk</path>
<platform>19</platform>
</sdk>
...
</configuration>
</plugin>

不工作

 <properties>
<android.sdk.path>/absolute/path/to/sdk</android.sdk.path>
</properties>

不起作用。和

mvn clean install -Dandroid.sdk.path=/absolute/path/to/sdk

不起作用。

我也试过将SDK中的tools、platform-tools和build-tools/19.1.1目录追加到$PATH中,也没有用。 aapt 工具在我的路径上可用,但 maven 插件拒绝看到它。我在网上搜索过,我看到的唯一建议就是按照我已经做过的去做。

我错过了什么?我在 OSX 系统上执行此操作。

最佳答案

旧版本的 Android Maven 插件可能无法与最新的 SDK 一起使用。例如,在 3.6.0 版本中添加了对 SDK 22 的支持。检查changelog .

3.6.0

The plugin has been updated to work with the SDK release 22.0. 21.1 works on the CI server. It might or might not work for older versions.

您不需要在 pom.xml 中配置 ANDROID_HOME,我的工作配置如下所示:

<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.8.2</version>

<configuration>
<sdk>
<platform>19</platform>
</sdk>
</configuration>
</plugin>

正确配置ANDROID_HOME,对我来说这指向

.../adt-bundle-linux-x86_64-20131030/sdk/

在调用 maven 之前,请确保它已正确配置。例如简单地运行 echo $ANDROID_HOME

关于android - 无法让 android-maven-plugin 识别 SDK 路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21374015/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com