生命周期配置未涵盖的插件执行:com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.5.0:generate-sources

时间:2013-03-05 21:31:56

标签: java android eclipse maven maven-3

我有一个Android应用程序,它是使用下面给出的pom.xml文件构建的。 mvn clean install可以正常运行,但在Eclipse中我遇到以下错误:

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)

我该如何修复它们?

这是pom.xml文件:

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

更新1(06.03.2013):以下是已安装插件的列表。

enter image description here

更新2(08.03.2013):您可以在下方找到更新的pom.xml。现在,我在下面的XML代码中的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)标记的地方收到了另一个错误 - <!-- Error occurs here -->

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

更新3(08.03.2013):当我以这种方式更改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>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>

从Eclipse运行应用程序,我收到以下错误:

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)

当我使用mvn clean install; mvn android:emulator-start; mvn android:deploy运行相同的应用程序时,一切正常。

更新4(2013年11月11日00:24 MSK):以下是我的新eclipse安装中安装的插件列表:

List of plugins

更新5(12.03.2013 23:22 MSK):这是类路径(似乎包含了achartengine):

Classpath

您也可以下载我的Eclipse installation

2 个答案:

答案 0 :(得分:3)

解决此问题的一种方法是将以下部分添加到 pom.xml (或父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>

答案 1 :(得分:0)

我在 Spring Tool Suite 4版本:4.6.0.RELEASE)上遇到了完全相同的问题。

我是如何修复它的。

第 1 步。将鼠标悬停在 pom.xml 中的执行元素上

enter image description here

第 2 步。 选择“在 pom.xml 中将目标编译标记为忽略”或“标记目标在 Eclipse 首选项中编译为忽略”,具体取决于您是要忽略项目级别还是 IDE 级别的执行。

第 3 步。 在包资源管理器中右键单击您的项目,然后“Maven --> 更新项目