17

I have an Android application, which is built using pom.xml file given below. mvn clean install works without errors, but in Eclipse I get following errors:

Plugin execution not covered by lifecycle configuration: com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.5.0:generate-sources (execution: default-generate-sources, phase: generate-sources)
Plugin execution not covered by lifecycle configuration: com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.5.0:proguard (execution: default-proguard, phase: process-classes)

How can I fix them?

Here's the pom.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.mycompany</groupId>
    <artifactId>myapp-android</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>apk</packaging>
    <name>myappAndroidClient</name>

    <repositories>
        <repository>
            <id>achartengine</id>
            <name>Public AChartEngine repository</name>
            <url>https://repository-achartengine.forge.cloudbees.com/snapshot/</url>
        </repository>       
    </repositories>

    <dependencies>
        <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>android</artifactId>
            <version>4.1.1.4</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.8.2</version>
            <scope>compile</scope>
        </dependency>
        <!-- Make sure this (robolectric dependency) is below the android dependencies -->
        <dependency>
            <groupId>com.pivotallabs</groupId>
            <artifactId>robolectric</artifactId>
            <version>1.0-RC4</version>
        </dependency>
        <dependency>
            <groupId>org.achartengine</groupId>
            <artifactId>achartengine</artifactId>
            <version>1.1.0</version>
        </dependency>               
    </dependencies>
    <build>
        <finalName>${project.artifactId}</finalName>
        <sourceDirectory>src</sourceDirectory>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>1.6</source>
                        <target>1.6</target>
                        <encoding>UTF-8</encoding>
                    </configuration>
                </plugin>

                <plugin>
                    <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                    <artifactId>android-maven-plugin</artifactId>
                    <version>3.5.0</version>

                    <extensions>true</extensions>

                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>android-maven-plugin</artifactId>
                    <configuration>
                        <sdk>
                            <!-- platform or api level (api level 4 = platform 1.6) -->
                            <platform>17</platform>
                            <path>C:\Program Files\adt-bundle-windows-x86\adt-bundle-windows-x86\sdk</path>
                        </sdk>
                    </configuration>
            </plugin>
        </plugins>
    </build>
    <reporting>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>javancss-maven-plugin</artifactId>
                <version>2.0</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-pmd-plugin</artifactId>
                <configuration>
                    <targetJdk>1.7</targetJdk>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <configLocation>altruix-checkstyle.xml</configLocation>
                    <includeTestSourceDirectory>true</includeTestSourceDirectory>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>cobertura-maven-plugin</artifactId>
                <version>2.5.2</version>
                <configuration>
                    <formats>
                        <format>html</format>
                        <format>xml</format>
                    </formats>
                    <instrumentation>
                        <excludes>
                            <exclude>**/*Test.class</exclude>
                        </excludes>
                    </instrumentation>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-project-info-reports-plugin</artifactId>
                <version>2.0.1</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-site-plugin</artifactId>
                <version>2.2</version>
                <configuration>
                    <inputEncoding>UTF-8</inputEncoding>
                    <outputEncoding>UTF-8</outputEncoding>
                    <locales>en</locales>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>findbugs-maven-plugin</artifactId>
                <version>2.5.2</version>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jdepend-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </reporting>
</project>

Update 1 (06.03.2013): Here's the list of installed plugins.

enter image description here

Update 2 (08.03.2013): Below you can find the updated pom.xml. Now I get another error - Plugin execution not covered by lifecycle configuration: com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.5.0:proguard (execution: default-proguard, phase: process-classes) at the place marked by <!-- Error occurs here --> in the XML code below.

    <build>
        <finalName>${project.artifactId}</finalName>
        <sourceDirectory>src</sourceDirectory>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>1.6</source>
                        <target>1.6</target>
                        <encoding>UTF-8</encoding>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                                        <artifactId>android-maven-plugin</artifactId>
                                        <versionRange>[3.5.0,)</versionRange>
                                        <goals>
                                            <goal>generate-sources</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore />
                                    </action>
                                </pluginExecution>
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                    <artifactId>android-maven-plugin</artifactId>
                    <version>3.5.0</version>
                    <extensions>true</extensions>

                </plugin>

                <plugin>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>2.5</version>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin> <!-- Error occurs here -->
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <configuration>
                    <sdk>
                        <!-- platform or api level (api level 4 = platform 1.6) -->
                        <platform>17</platform>
                        <path>C:\Program Files\adt-bundle-windows-x86\adt-bundle-windows-x86\sdk</path>
                    </sdk>
                </configuration>
            </plugin>
        </plugins>
    </build>

Update 3 (08.03.2013): When I change the pom.xml file in this way

<plugin>
    <groupId>org.eclipse.m2e</groupId>
    <artifactId>lifecycle-mapping</artifactId>
    <version>1.0.0</version>
    <configuration>
        <lifecycleMappingMetadata>
            <pluginExecutions>
                <pluginExecution>
                    <pluginExecutionFilter>
                        <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                        <artifactId>android-maven-plugin</artifactId>
                        <versionRange>[3.5.0,)</versionRange>
                        <goals>
                            <goal>generate-sources</goal>
                            <goal>proguard</goal>
                            <goal>emma</goal>
                            <goal>dex</goal>
                            <goal>internal-pre-integration-test</goal>
                            <goal>internal-integration-test</goal>
                        </goals>
                    </pluginExecutionFilter>
                    <action>
                        <ignore />
                    </action>
                </pluginExecution>
            </pluginExecutions>
        </lifecycleMappingMetadata>
    </configuration>
</plugin>
<plugin>
    <groupId>com.jayway.maven.plugins.android.generation2</groupId>
    <artifactId>android-maven-plugin</artifactId>
    <version>3.5.0</version>
    <extensions>true</extensions>

</plugin>

and run the application from Eclipse, I get following error:

FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: co.altruix.ccp.android.impl.viewtype2fragmentmapper.DefaultViewTypeToFragmentMapper
    at co.altruix.ccp.android.impl.activities.MainActivity.<init>(MainActivity.java:22)
    at java.lang.Class.newInstanceImpl(Native Method)
    at java.lang.Class.newInstance(Class.java:1319)
    at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
    at android.app.ActivityThread.access$600(ActivityThread.java:141)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:5039)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
    at dalvik.system.NativeStart.main(Native Method)

When I run the same application using mvn clean install; mvn android:emulator-start; mvn android:deploy, everything works fine.

Update 4 (11.03.2013 00:24 MSK): Here's the list of installed plugins in my new eclipse installation:

List of plugins

Update 5 (12.03.2013 23:22 MSK): Here's the classpath (achartengine seems to be included):

Classpath

You can also download my Eclipse installation.

Glory to Russia
  • 17,289
  • 56
  • 182
  • 325
  • 2
    It looks like you are missing a [m2e connector](http://objectledge.org/confluence/display/TOOLS/M2E+Connectors) required to integrate the maven-android-plugin to Eclipse. Have you [installed the connector](http://rgladwell.github.com/m2e-android/)? – sbk Mar 05 '13 at 23:41
  • I can't. There is no menu item `Help -> Eclipse Marketplace` in my IDE. – Glory to Russia Mar 06 '13 at 17:56
  • @sbk See **update 1** with a list of all installed Eclipse plugins. – Glory to Russia Mar 06 '13 at 18:56
  • Did you download the Eclipse from the Android web site rather than from eclipse.org directly? – Ricardo Gladwell Mar 09 '13 at 13:08
  • Looks as though you already have m2e-android installed. Can you verify this? – Ricardo Gladwell Mar 09 '13 at 13:14
  • @RicardoGladwell 1) AFAIR I downloaded Eclipse from the Android web site. 2) How can I verify that m2e-android is installed? – Glory to Russia Mar 09 '13 at 17:10
  • It should be in the list of installed plugins as 'Android Connector'. If that fails you can try installing Eclipse from eclipse.org and install the plugins yourself. – Ricardo Gladwell Mar 09 '13 at 20:03
  • @RicardoGladwell Re-installing eclipse from eclipse.org didn't help. I still get the `java.lang.NoClassDefFoundError: co.altruix.ccp.android.impl.viewtype2fragmentmapper.DefaultViewTypeToFragmentMapper` exception when launching the app from eclipse. – Glory to Russia Mar 10 '13 at 20:14
  • 1
    @DmitriPisarenko, _How can I verify that m2e-android is installed?_ See [this answer](http://stackoverflow.com/questions/11023252/how-do-you-install-m2e-android-plugin-in-eclipse/11023584#11023584). – yorkw Mar 10 '13 at 20:14
  • @yorkw Thanks. See "Update 4" with a list of plugins in my eclipse IDE. – Glory to Russia Mar 10 '13 at 20:30
  • 2
    How did you import the project? The correct way is to use `File - Import... - Maven - Existing Maven Projects` import the mavenized android project. – yorkw Mar 10 '13 at 21:14
  • @DmitriPisarenko is the achartengine dependency appearing in your classpath? Did you verify if m2e-android is installed? – Ricardo Gladwell Mar 11 '13 at 17:15
  • @yorkw I deleted the existing project, then imported it as you explained. I get same results (`NoClassDefFoundError`). – Glory to Russia Mar 11 '13 at 20:15
  • @RicardoGladwell Regarding m2e-android - as you can see in the screenshot in "Update 4", there is a plugin called "Android configurator for M2E", from which I conclude that m2e-android is installed. – Glory to Russia Mar 12 '13 at 09:31
  • @DmitriPisarenko cool, is the achartengine dependency appearing in your classpath? – Ricardo Gladwell Mar 12 '13 at 13:46
  • @RicardoGladwell According to the project properties - yes. See the screenshot in "Update 5". – Glory to Russia Mar 12 '13 at 19:24
  • To help you debug my issue, I added the link to 7zipped archive of my eclipse installation. – Glory to Russia Mar 12 '13 at 19:26
  • See the link below the screenshot in "Update 5". – Glory to Russia Mar 12 '13 at 19:47
  • @All: Are there any pieces of information that might help you answer the question (and which I didn't provide yet) and get the bounty? – Glory to Russia Mar 13 '13 at 06:52

2 Answers2

3

One way to solve it is by adding the following section to your pom.xml (or parent pom.xml):

<plugin>
   <groupId>org.eclipse.m2e</groupId>
   <artifactId>lifecycle-mapping</artifactId>
   <version>1.0.0</version>
   <configuration>
      <lifecycleMappingMetadata>
         <pluginExecutions>
            <pluginExecution>
               <pluginExecutionFilter>
                  <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                  <artifactId>android-maven-plugin</artifactId>
                  <versionRange>[3.5.0,)</versionRange>
                  <goals>                                                               
                     <goal>generate-sources</goal>      
                     <goal>proguard</goal>
                     <goal>emma</goal>
                     <goal>dex</goal>
                     <goal>apk</goal>
                     <goal>internal-pre-integration-test</goal>
                     <goal>internal-integration-test</goal>                                         
                  </goals>
               </pluginExecutionFilter>
               <action>
                  <execute />
               </action>
            </pluginExecution>
         </pluginExecutions>
      </lifecycleMappingMetadata>
   </configuration>
</plugin>
lacton
  • 2,316
  • 2
  • 22
  • 24
asgoth
  • 35,552
  • 12
  • 89
  • 98
0

I had the exact same issue on my Spring Tool Suite 4 (Version: 4.6.0.RELEASE).

How i fixed it.

Step 1. Hover over the execution element in your pom.xml

enter image description here

Step 2. Select either "Mark goal compile as ignored in pom.xml" or "Mark goal compile as ignored in eclipse preferences" depending on whether you want to ignore the execution at your project level or on your IDE level.

Step 3. Right click on your project in the package explorer and "Maven --> Update project"

Abdullah Khan
  • 12,010
  • 6
  • 65
  • 78