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

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 :( )

---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:
Update to maven 3.1.1
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)
I ran $PATH_TO_YOUR_ANDROID_SDK/android update sdk --no-ui --all --force
I deleted my ~/.m2 directory
I ran mvn clean install and everything worked

Related

Invalid SDK: Platform/API level 19 not available [duplicate]

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 :( )
---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:
Update to maven 3.1.1
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)
I ran $PATH_TO_YOUR_ANDROID_SDK/android update sdk --no-ui --all --force
I deleted my ~/.m2 directory
I ran mvn clean install and everything worked

Maven plug in could not read ${env.ANDROID_HOME}

Note:
1) I am using Ubuntu 14.04, Apache Maven 3.2.2, Eclipse Luna Release (4.4.0), ADT Version 23.0.2.1259578, installed m2e plugin for eclipse.
2) Refered to this question android maven plugin does not get ANDROID_HOME env variable in Eclipse
This is part of my pom.xml
<properties>
<!-- use UTF-8 for everything -->
<android.sdk.path>${env.ANDROID_HOME}</android.sdk.path>
<android.sdk.platform>18</android.sdk.platform>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
I have set ANDROID_HOME="my_sdk_path" in /etc/environment
printenv ANDROID_HOME in the terminal outputs my SDK path and it is correct.
Problem:
When I run maven build - setting goals as "install android:deploy android:run", it shows that it could not find SDK path. But, when I hardcode as in
<android.sdk.path>my_sdk_path</android.sdk.path>
as my SDK path in my pom.xml, it works fine.
Seems like ${env.ANDROID_HOME} cannot be read properly.
Any help would be greatly appreciated. Thanks.

Last ADT update (22.6.3) spoiled my Eclipse

I am using mavenized library project with the following plugin:
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.6.0</version>
<extensions>true</extensions>
<configuration>
<nativeLibrariesDirectory>ignored</nativeLibrariesDirectory>
<attachSources>true</attachSources>
</configuration>
</plugin>
But after the last update of the ADT (22.6.3) everything went wrong, the JAR is not built by Eclipse, and I got error messages of lyfecicle like this:
Description Resource Path Location Type Conflicting lifecycle mapping
(plugin execution
"com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.6.0:proguard
(execution: default-proguard, phase: process-classes)"). To enable
full functionality, remove the conflicting mapping and run
Maven->Update Project Configuration. pom.xml /actionbarsherlock line 1
Maven Project Build Lifecycle Mapping Problem
I have followed those instructions in order to solve the problems, and indeed they are gone, but the JAR is not being built.
Also tried with this: com.jayway.maven.plugins.android.generation2: Plugin execution not covered by lifecycle configuration? but no success.
This is my Eclipse (Kepler) Installation Details:
Android Configurator for M2E 1.0.0 me.gladwell.eclipse.m2e.android.feature.feature.group Gladwell.me
Android DDMS 22.6.3.v201404151837-1123206 com.android.ide.eclipse.ddms.feature.group The Android Open Source Project
Android Development Tools 22.6.3.v201404151837-1123206 com.android.ide.eclipse.adt.feature.group The Android Open Source Project
Android Hierarchy Viewer 22.6.3.v201404151837-1123206 com.android.ide.eclipse.hierarchyviewer.feature.group The Android Open Source Project
Android Traceview 22.6.3.v201404151837-1123206 com.android.ide.eclipse.traceview.feature.group The Android Open Source Project
Eclipse IDE for Java EE Developers 2.0.2.20140224-0000 epp.package.jee null
Genymotion Eclipse Tools 1.0.3.201403261147 com.genymobile.genymotion.ide.eclipse.feature.group Genymobile
m2e - Maven Integration for Eclipse 1.4.1.20140328-1905 org.eclipse.m2e.feature.feature.group Eclipse.org - m2e
m2e - slf4j over logback logging (Optional) 1.4.1.20140328-1905 org.eclipse.m2e.logback.feature.feature.group Eclipse.org - m2e
Tracer for OpenGL ES 22.6.3.v201404151837-1123206 com.android.ide.eclipse.gldebugger.feature.group The Android Open Source Project
Any ideas?
We had this issue an after rebuilding the whole environment again (newest Eclipse Juno J2EE + newest maven-android plugin) figured out that the problem was exactly in the maven-android plugin. It has an update issue: output directory set to target/classes instead of bin/classes. This can be fixed unchecking the "Allow output folder for source folders" box in the source tab of the build path of each project. For more info about that please check this:
https://github.com/rgladwell/m2e-android/issues/219
I had exactly the same problem.
I end up installing the latest version of Eclipse, and then add the Android software repo on it and everything is working now.
Try change version to 3.9.0-rc.1:
<dependency>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.9.0-rc.1</version>
</dependency>
Works for me.
Has the same issue ! I simply downloaded the last version of Eclipse here : http://developer.android.com/sdk/index.html#ExistingIDE
It includes the Android SDK => nothing else to download. Works perfectly directly.
And what is really great is that my whole workspace (projects opened in Eclipse, signatures, etc...) has been recovered. Nothing to do ! Just download, place in any folder on your computer (a Mac in my case), and start to work with the last Eclipse version.
Really happy :)

ADT 22 - missing aapt.exe after upgrading

At work, I need to use maven with Android.
maven uses appt.exe for its own compiling process.
ever since I've upgraded to ADT 22 , maven says it can't find this file, and it's right- the file is gone from "...\platform-tools" .
I've tried to uninstall&re-install the sdk manager and the ADT , but it didn't help.
What can I do to fix this ?
Why is it gone?
EDIT:
For now, I use a workaround of copying (without replacing) all of the old "platform-tools" files into the current one. It seems to work, but maybe it could cause problems.
It's moved to:
path/to/your/android-sdk/build-tools/17.0.0/...
I'm assuming this it to ad versioning to the build tools.
We need the android-maven-plugin to do a fix! As its looking for the files under platform-tools/... which of course they are not anymore.
Update - Fixed
Update your pom.xml to 3.6.0 (or greater). The android-maven-plugin has been updated to support the new structure.
See 3.6.0 Released
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.6.0</version>
<inherited>true</inherited>
<configuration>
<sdk>
<platform>${android.platform}</platform>
</sdk>
</configuration>
</plugin>
Temp Fix (Old - See Fix)
As mentioned by the OP, copy the files from /build-tools/17.0.0/... to /platform-tools until the maven plugin is fixed.
For unix users
cp -r build-tools/17.0.0/* platform-tools/
From your android sdk folder.
The correct fix is to clone the android-maven-plugin wich is actually up to date with the latest developper tools but not yet released in central maven repository :
Clone the android-maven-plugin on GitHub and install it in your repo
git clone https://github.com/jayway/maven-android-plugin.git
cd .../maven-android-plugin/
mvn clean install
Then update your pom to use version 3.5.4-SNAPSHOT of the plugin.
Everything should work properly !
You need add ~/sdk/build-tools to you $PATH
Just make sure you've installed Build-tools. Unfortunately you need to run SDK manager twice.
For the first time to upgrade Tools to revision 22, then close it (reload from menu doesn't work) and run again. After refresh you'll see an update of Platform-Tools to revision 17 and new package called Build-tools that contains aapt.
Hope it helps.

How do you install m2e-android-plugin in Eclipse?

I am trying to get setup to use Maven and pom.xml files in Eclipse for my Android projects. I have Eclipse Indigo setup (m2e included), Android SDK installed, ADT installed. I am struggling to understand what it means to "Install the m2e-android-plugin" (I am always taken to this page which provides instructions on installing it, but which I cannot follow) Specifically, when I go through the instruction on that page, after I complete all the steps in part 2, my structure does not have "Maven Dependencies" and my pom.xml file shows the following error:
Project build error: Unresolveable build extension: Plugin
com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.1.1 or one of its dependencies could
not be resolved: The following artifacts could not be resolved:
com.jayway.maven.plugins.android.generation2:android-maven-plugin:jar:3.1.1,
com.android.ddmlib:ddmlib:jar:r16, org.sonatype.sisu:sisu-inject-bean:jar:2.1.1,
org.sonatype.sisu:sisu-guice:jar:no_aop:2.9.4, org.codehaus.plexus:plexus- archiver:jar:2.0.1, junit:junit:jar:3.8.1,
org.codehaus.plexus:plexus-io:jar:2.0.1, org.codehaus.plexus:plexus-utils:jar:3.0, commons-jxpath:commons-
jxpath:jar:1.3, commons-io:commons-io:jar:2.0.1, org.ow2.asm:asm:jar:4.0, commons-lang:commons-lang:jar:
2.6, org.sonatype.aether:aether-util:jar:1.12: Failure to transfer
com.jayway.maven.plugins.android.generation2:android-maven-plugin:jar:3.1.1 from http://repo1.maven.org/
maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central
has elapsed or updates are forced. Original error: Could not transfer artifact
com.jayway.maven.plugins.android.generation2:android-maven-plugin:jar:3.1.1 from/to central (http://
repo1.maven.org/maven2): No response received after 60000
along with:
Project build error: Unknown packaging: apk
on the line
<packaging>apk</packaging>
I have tried set up a fresh second IDE myself and everything works as expected, suppose you have installed both Android SDK and Maven properly (better to use latest version), these are the only Eclipse plugins required to work with Mavenized Android Project:
adt
m2e
m2e-android
Check out my screenshot Help -> Install New Software... -> what is already installed:
If you follow instructions from this page starting with a new project, the <packaging> error is most likely due to earlie version of maven-release-plugin (if you do not explicitly specify one). By hovering mouse on <packaging> element in pom.xml, you should get some hint like:
maven-resources-plugin prior to 2.4 is not supported by m2e. Use maven-resources-plugin version 2.4 or later.
Adding the following plugin under <plugins>:
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
</plugin>
Then Right-click on new project and select Maven -> Update Project Configuration, this should fix all error and give you a working example.
I had the same problem trying to install the android m2e in eclipse JUNO.
Then tried to install through "Install new software" wizard, instead of market place.
Add the following as an update site and select "Android For Maven eclipse" from the listed softwares and install.
http://rgladwell.github.com/m2e-android/updates - Thanks to #NullNoname for providing the update site.

Categories

Resources