Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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>
like image 846
Leo Avatar asked Jun 13 '12 21:06

Leo


1 Answers

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:

enter image description here

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.

like image 77
yorkw Avatar answered Sep 21 '22 06:09

yorkw