MAVEN 无效的 SDK:平台/API 级别 16 不可用 [英] MAVEN Invalid SDK: Platform/API level 16 not available

查看:28
本文介绍了MAVEN 无效的 SDK:平台/API 级别 16 不可用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 Android Studio (windows) 上有一个可用的 android 应用程序,我正在尝试使用 MAVEN 为该项目创建一个 apklib.

I have a working android app on my Android Studio (windows) and I am trying to create an apklib with MAVEN for the project.

当我在 MAVEN (3.0.5) 上运行编译时,我收到以下错误消息:

When I run compile on MAVEN (3.0.5) I get the following error message:

Failed to execute goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.6.0:generate-sources (default-generate-sources) on project userprofile: Execution default-generate-sources of goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.6.0:generate-sources failed: Invalid SDK: Platform/API level 16 not available. This command should give you all you need:
[ERROR] C:\Program Files (x86)\Android\android-studio\sdk\tools\android update sdk --no-ui --obsolete --force

我运行了上面的命令来更新 sdk 但没有成功(它成功了,但我一直收到上述错误).我的 SDK 管理器显示已安装 API 16.

I run the above command for update sdk but no luck (it was successful, but I keep get the above error). My SDK Manager shows that API 16 is installed.

有什么想法吗?(网络上的所有问题都总结为在 SDK Manager 上安装 API :( )

Any ideas? (all questions on web conclude to install the API on SDK Manager :( )

推荐答案

---EDIT---

还有一个错误,因为我将 settings.xml 设置为不正确的 android SDK 主路径.我将我的 ~/.m2/settings.xml 文件更新为正确的 SDK 路径并将我的 $ANDROID_HOME 变量设置为正确的路径,这已得到修复.

There was also an error because I had my settings.xml set to the incorrect android SDK home path. I updated my ~/.m2/settings.xml file to the correct SDK path and set my $ANDROID_HOME variable to the correct path and this was fixed.

我能够通过以下更改克服此错误:

I was able to get past this error with the following changes:

  1. 更新到 maven 3.1.1
  2. 在我的 pom.xml 中我改变了

<代码><插件><groupId>com.jayway.maven.plugins.android.generation2 </groupId><artifactId>android-maven-plugin</artifactId><version>3.7.0</version></插件>

致:<代码><插件><groupId>com.jayway.maven.plugins.android.generation2</groupId><artifactId>android-maven-plugin</artifactId><version>3.8.1</version><配置><平台>19</平台></sdk></配置></插件>
(请注意此更改对 最新插件版本 (3.8.1) 并指定 sdk 的平台)

To: <plugin> <groupId>com.jayway.maven.plugins.android.generation2</groupId> <artifactId>android-maven-plugin</artifactId> <version>3.8.1</version> <configuration> <sdk> <platform>19</platform> </sdk> </configuration> </plugin>
(note this change both updates to the latests plugin version (3.8.1) and specifies the platform for the sdk)

  1. 我运行了 $PATH_TO_YOUR_ANDROID_SDK/android update sdk --no-ui --all --force

我删除了我的 ~/.m2 目录

I deleted my ~/.m2 directory

我运行了 mvn clean install 一切正常

这篇关于MAVEN 无效的 SDK:平台/API 级别 16 不可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆