Home » Android » java – Error in maven pom xml file: Building Android project

java – Error in maven pom xml file: Building Android project

Posted by: admin June 15, 2020 Leave a comment

Questions:

I am getting the error in plugin tag in pom xml file. The error is on plugin tag, before groupId.

Error:-

Plugin execution not covered by lifecycle configuration:com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.8.2:consume-aar (execution: default-consume-aar, phase: compile)

Any one knows how to resolve this problem. Below mentioned is the pom.xml file contents

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.simpligility.android</groupId>
  <artifactId>helloflashlight</artifactId>
  <version>1.0.0</version>
  <packaging>apk</packaging>

  <name>HelloFlashlight</name>

  <dependencies>
    <dependency>
      <groupId>com.google.android</groupId>
      <artifactId>android</artifactId>
      <version>4.1.1.4</version>
      <scope>provided</scope>
    </dependency>
  </dependencies>

  <build>
    <sourceDirectory>src</sourceDirectory>
    <finalName>${project.artifactId}</finalName>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>com.jayway.maven.plugins.android.generation2</groupId>
          <artifactId>android-maven-plugin</artifactId>
          <version>3.8.2</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 as api level (api level 16 = platform 4.1)-->
            <platform>16</platform>
          </sdk>
        </configuration>
      </plugin>
    </plugins>
  </build>

</project>
How to&Answers:

To silence the error in pom.xml the following could be added in there:

    <pluginManagement>
     <plugins>
      <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>[1.0.0,)</versionRange>
              <goals>
               <goal>consume-aar</goal>
              </goals>
             </pluginExecutionFilter>
            <action>
             <ignore />
            </pluginExecution>
           </action>
           </pluginExecutions>
          </lifecycleMappingMetadata>
         </configuration>
       </plugin>
       . . . 

Answer:

That is because of new m2eclipse plugin, a feature of it newly introduced.

For all the build executions that are specified in your pom.xml if there are respective config information in lifecycle-mapping-metadata.xml file of m2eclipse plugin, It shows that error.

You can get more info here

You can ignore that error, that doesn’t effect your project execution.

Answer:

Eclipse M2E warns you that your lifecycle contains an unknown plugin. M2E cannot decide, whether it is irrelevant and can be ignored or it is an integral part of your lifecycle.

This information can either be provided as entry in your pom.xml, in a special lifecycle-file for your eclipse or by installing a specific configuration plugin, which is usually the best solution.

In your case, there exists a configurator plugin for the android-maven-plugin, take a look at: http://rgladwell.github.io/m2e-android/, which should solve your problem quite neatly.

Answer:

To solve the problem , we must add in the pom.xml all of the following elements :

<plugin>
    <groupId>org.eclipse.m2e</groupId>
    <artifactId>lifecycle-mapping</artifactId>
    <version>1.0.0</version>
</plugin>

Here is the final 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>testMyc</groupId>
    <artifactId>srgfrzfd</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>apk</packaging>
    <name>srgfrzfd</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <platform.version> 4.1.1.4
            </platform.version>
        <android.plugin.version>3.8.2</android.plugin.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>android</artifactId>
            <version>${platform.version}</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    <build>
        <finalName>${project.artifactId}</finalName>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                    <artifactId>android-maven-plugin</artifactId>
                    <version>${android.plugin.version}</version>
                    <extensions>true</extensions>
                </plugin>
            </plugins>
            <plugin>
                <groupId>org.eclipse.m2e</groupId>
                <artifactId>lifecycle-mapping</artifactId>
                <version>1.0.0</version>
            </plugin>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <configuration>
                    <sdk>
                        <platform>16</platform>
                    </sdk>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

and the following tag in the “lifecycle-mapping-metadata.xml” file that is in the “Windows” > and preferably maven > lifecycle mapping > ” Open workspace lifecycle mapping metadata ” eclipse menu

<?xml version="1.0" encoding="UTF-8"?>
<lifecycleMappingMetadata>
    <pluginExecutions>
        <pluginExecution>
            <pluginExecutionFilter>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <versionRange>[1.0.0,)</versionRange>
                <goals>
                    <goal>consume-aar</goal>
                </goals>
            </pluginExecutionFilter>
            <action>
                <ignore />
            </action>
        </pluginExecution>
    </pluginExecutions>
</lifecycleMappingMetadata>

Save the file in your workspace in use .

Answer supplied set by myc1986

Answer:

As of Maven Eclipse (m2e) version 0.12 all Maven life-cycle goals must map to an installed m2e extension. In this case, the android-maven-plugin added a new goal, consume-aar to support the new Android Library archive format.

The Android for Maven Eclipse (m2e-android) plugin does not have AAR support yet (because Google have not added AAR support to the ADT yet) so this goal is unmapped and this is why you’re getting this error message.

You can exclude un-mapped life-cycle goals by simply following the instructions here:

https://wiki.eclipse.org/M2E_plugin_execution_not_covered

Alternatively, simply right-click on the error message in Eclipse and choosing Quick Fix -> Ignore for every pom with such errors.