Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
241 views
in Technique[技术] by (71.8m points)

android - MAVEN Invalid SDK: Platform/API level 16 not available

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

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)Androidandroid-studiosdkoolsandroid update sdk --no-ui --obsolete --force

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.

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

---EDIT---

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. Update to maven 3.1.1
  2. in my pom.xml I changed

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

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. I ran $PATH_TO_YOUR_ANDROID_SDK/android update sdk --no-ui --all --force

  2. I deleted my ~/.m2 directory

  3. I ran mvn clean install and everything worked


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...