MAVEN Invalid SDK: Level 16 for platform / API unavailable

I have an Android application in Android Studio (windows) and I'm trying to create apklib with MAVEN for a project.

When I run compilation in MAVEN (3.0.5), the following error message appears:

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 

I ran the above command to update sdk but no luck (this was successful, but I keep getting the above error). My SDK manager shows that API 16 is installed.

Any ideas? (all questions on the Internet are how to install the API on the SDK Manager :()

+6
source share
1 answer

--- EDIT ---

There was also an error, because my setup.xml had the wrong source SDK path for Android installed. I updated the ~ / .m2 / settings.xml file to the correct SDK path and set the $ ANDROID_HOME variable to the correct path and this was fixed.


I managed to skip this error with the following changes:

<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 that this change is both the update and the version of the plugins for latests (3.8.1) and defines the platform for sdk)

  • I ran $PATH_TO_YOUR_ANDROID_SDK/android update sdk --no-ui --all --force

  • I deleted the ~ / .m2 directory

  • I ran mvn clean install and everything worked

+4
source

Source: https://habr.com/ru/post/946952/


All Articles