6

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)\Android\android-studio\sdk\tools\android 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 :( )

geoak
  • 442
  • 7
  • 18
  • 1
    possible duplicate of [Error building Android project with Maven: Platform/API level 16 not available](http://stackoverflow.com/questions/17023461/error-building-android-project-with-maven-platform-api-level-16-not-available) – naXa stands with Ukraine Dec 03 '14 at 12:13

1 Answers1

5

---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

taylorstine
  • 905
  • 7
  • 17
  • 1
    this only happens to me while building the project through jenkins. In my scenario something happens related to jenkins, If I try to build via mvn console (using "mvn compile" for instance) everything goes perfectly, do you have any advice? – Mustafa Güven Jan 31 '14 at 12:10
  • What exactly does 1. do? I did it and it didn't have any effect. – Al Lelopath Oct 23 '15 at 17:14
  • @taylorstine Why/how would you have the SDK path set in your maven settings.xml? o_O. I modified my pom as you describe, but during the build Maven keeps donwloading 3.6.0 android-maven-plugin. It just ignores the 3.8.1. In my case the plugin is trippin' about API level 15, although it is installed. Weird. – Csaba Toth Nov 30 '15 at 05:40
  • Got it: http://stackoverflow.com/questions/19133913/maven-android-pluginno-android-sdk-path-could-be-found – Csaba Toth Nov 30 '15 at 05:42
  • And that solved it. So the shell what the plugin starts doesn't pick up the ANDROID_HOME env variable. Crafting a settings.xml helped. Unbelievable. – Csaba Toth Nov 30 '15 at 05:47
  • What do we do now that the android command is not available. When running `$PATH_TO_YOUR_ANDROID_SDK/android update sdk --no-ui --all --force` : I get the error: `The android command is no longer available. For manual SDK and AVD management, please use Android Studio. For command-line tools, use tools/bin/sdkmanager and tools/bin/avdmanager` – eriel marimon Oct 27 '17 at 15:45