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

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.

Related

Android Studio refuses to accept that Google Repository is installed

I am trying to get AdMob running. But for some strange reason, I can not get Android Studio to accept that the Google Repository is installed.
Thing is, it is installed in the SDK manager. And reinstalled multiple times now. Project Structure SDK path is the same as in Android SDK Manager.
When I mouse over the compile 'com.google.android.gms:play-services:6.+' line in my build.gradle, I get this tooltip:
"Dependency on Play Services, but the SDK installation does not have the "Extras > Google Repository" installed. Open the SDK manager and install it"
When I try to compile, this error:
Error:Failed to resolve: com.google.android.gms:play-services:6.+
With that error comes a link to install the Repository, which I used multiple times now. Android Studio does not care. Help.
edit: When I use a fresh empty project, it works, and Android Studio finds the Repository. No clue what is going on here.
I was suffering with the same problem and finally found a simple solution (I'm using Android Studio 1.5.1 on MacOS):
Go to File --> Project Structure
On the left hand of the opened window, under Developer Services, select Ads
Check the checkbox next to AdMod. Your window should look like this:
Click OK
This will add the required dependency to the Android's build.gradle, and sync Gradle.
When the sync is done, and just to make sure, clean and rebuild your project:
Build --> Clean Project
Build --> Rebuild Project
That's it! I hope this helps.

How to build a Maven Android project in eclipse

I am testing the code here : https://github.com/nkzawa/socket.io-client.java. Under features there is this sweet sounding line : "Android is fully supported". But being completely new to maven I can make neither head nor tail of the instructions. How do I build a basic Android test project with this code? Simply adding the source code from the repo to my project is showing lot of errors. If there is a command line way of doing this that would be fine too.
The Android for Maven Eclipse connector is an Maven Eclipse (m2e) plug-in that adds maven support for Android Developer Tools (ADT) and the Maven Android Plugin. It brings the power of Maven dependency management into the ADT.
Before you start
You will need Eclipse Indigo or Juno installed.
Install Android Connector
You can install the Android Connector for Maven via the Eclipse Marketplace. Select Help -> Eclipse Marketplace... and search for "android m2e".
Click the Install button next to the Android Connector for Maven that appears and follow the path through the wizard dialog to install the plug-in and its dependencies (including the Android Development Toolkit and the Maven for Eclipse m2e plug-in). Accept the terms-and-conditions and click Finish.
Once you restart your Eclipse workspace you should be ready to start using the Android Connector.
Create Eclipse project
If you already have an Android project please make sure you have created a POM for your project using version 3.0.0 or greater of the maven-android-plugin.
Then right-click on your project and select Configure -> Convert to Maven Project.
If you are starting with a new project you can use the Maven Android archetypes to create Android projects completely within Eclipse:
1. Create a new Maven Project (File -> New -> Project... then select Maven -> Maven Project).
2. When prompted to Select Archetype click Add Archetype...
3. In the dialog that appears enter "de.akquinet.android.archetypes" for Archetype Group Id.
4. In Archetype Artifact Id enter "android-quickstart".
5. In Archetype Version enter "1.0.10" and continue.
6. When prompted enter your desired project group and artifact ID, version and, optionally, set the "platform" property for the Android version (defaults to '16').
7. Click Finish
Either way you should end up with an Eclipse project looking something like this:
Steps to build a Maven Android project in eclipse
Install m2e(mavel plugin) to your ecplise.
Right click Create Maven project
Click next and in Catalog select Android
Give group id com.example and Artifact id Project name
click finish.
Typically you do this by importing an "Existing Maven Project". You get this option in the Import dialog when you have installed m2e. For Android you will additionally need the Android Connector before doing the import. Here it gets nasty. You can install the connector from Window -> Preferences -> Maven -> Discovery -> Open Catalog.
To be honest I had no luck with this connector yet. So the second option is (you don't even need m2e here):
Install Maven
Open the command line and navigate to your downloaded sources where the pom.xml is located
run mvn eclipse:eclipse to create eclipse project files
Import it as "Existing Project into Workspace" in the import dialog.
install m2e plug-in your eclipse.
install android m2e plug-in.
create new maven project.
select archtype:android-quickstart by typing android in filter.
finish you will get maven android project.
and add this plugin in pom
org.eclipse.m2e
lifecycle-mapping
1.0.0
com.jayway.maven.plugins.android.generation2
android-maven-plugin
[3.8.2,)
consume-aar
finally update the project by rightclicking on project->maven->update project.

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

Howto properly integrate Android SDK (Adt) and Maven :

I've created an android project based on android-release archetype (via mvn CLI).
In order to import it to eclipse ADT (version 21) I tried:
mvn eclipse:eclipse
The problem with this approach was that the created eclipse project was a Java project and didn't have an 'android' nature.
so I tried:
importing the pom.xml using M2E eclipse plugin (Maven Integration for Eclipse)
now I have 2 different problems:
the gen folder is not the one used by maven, and I have to add it as a source folder.
getting ClassNotFoundException for the unit test classes when running via eclipse. Maven has no problems at all.
is this how it supposed to work ? am I doing here something wrong, or I simply have too high expectations?

How to disable m2e build in Eclipse Indigo?

I'm currently using Eclipse Indigo in an Android project that I'm working on and am running into problems with the built-in Maven (m2e) builder. I use the ADT plug-in to build the project, but I also have a Maven pom.xml that's used to build the project from the command line. Once I switched from Helios to Indigo, I started seeing these errors:
Plugin execution not covered by lifecycle configuration: com.jayway.maven.plugins.android.generation2:maven-android-plugin:2.9.0-beta-5:generate-sources (execution: default-generate-sources, phase: generate-sources)
Plugin execution not covered by lifecycle configuration: com.jayway.maven.plugins.android.generation2:maven-android-plugin:2.9.0-beta-5:unpack (execution: default-unpack, phase: process-classes)
Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-jar-plugin:2.3.1:jar (execution: default-jar, phase: process-classes)
My goal is to keep the Maven build separate from the ADT Eclipse build so I'd like to simply disable m2e for the project but I can't figure out how to do that.
Is there a way to disable the m2e builder? Alternatively, is there a way to fix the above errors?
Open your POM and click on the "Plugin execution not covered by lifecycle configuration" error. This will give you the option to Discover new m2e connectors.
Select this and you should be automatically prompted to download and install the Android Connector.
Installing this should resolve your problems. You should probably uninstall the old 0.2.4 m2eclipse-android-integration as well in favour of the new 0.3.0 m2e-android version.
Please see the new site for more information:
http://rgladwell.github.com/m2e-android/
M2E official wiki documents this issue
I think you can use lifecycle-mapping plugin from m2e to silently ignore the execution for these plugins
I went into my install directory for Eclipse and manually removed all the references to m2e.
There were multiples in the "Plugin" directory and the "features" directory.
After that my android project was back to behaving like normal and I could use mvn from the command line to build.
I am using MacOSX with Eclipse 4.3 (Krepler). What I originally tried was to install Maven via the terminal using Brew. It installed correctly Maven 3.0.4. However when I tried to import any ready maven projects (File > Import > Maven) it would display the following two errors:
No marketplace entries found to handle Execution default-testResources
What I did is go to Help > Eclipse Marketplace and type "Maven" in the search bar and install the first default Maven client for Eclipse. Everything worked for me from this point.
Hope it helps to you too.

Categories

Resources