Al ejecutar la instrucción mvn clean compile android:dex android:apk
se produce el siguiente error por un fallo en la configuración del plugin android para maven:
[ERROR] Failed to execute goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.8.2:dex (default-cli) on project DemoPhoneGap-1: Execution default-cli of goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.8.2:dex failed: For artifact {DemoPhoneGap-1:DemoPhoneGap-1:0.0.1-SNAPSHOT:jar}: An attached artifact must have a different ID than its corresponding main artifact. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.8.2:dex (default-cli) on project DemoPhoneGap-1: Execution default-cli of goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.8.2:dex failed: For artifact {DemoPhoneGap-1:DemoPhoneGap-1:0.0.1-SNAPSHOT:jar}: An attached artifact must have a different ID than its corresponding main artifact.
Fichero pom.xml empleado en el proyecto:
<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>DemoPhoneGap-1</groupId> <artifactId>DemoPhoneGap-1</artifactId> <version>0.0.1-SNAPSHOT</version> <name>DemoPhoneGapBackbone</name> <build> <sourceDirectory>src</sourceDirectory> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> <plugin> <groupId>com.jayway.maven.plugins.android.generation2</groupId> <artifactId>android-maven-plugin</artifactId> <version>3.8.2</version> <!-- Url de documentación del plugin: http://jayway.github.io/maven-android-plugin/ --> <configuration> <androidManifestFile>${project.basedir}/AndroidManifest.xml</androidManifestFile> <assetsDirectory>${project.basedir}/assets</assetsDirectory> <sdk> <path>${env.ANDROID_HOME}</path> <platform>19</platform> </sdk> <dex> <jvmArguments> <jvmArgument>-Xms256m</jvmArgument> <jvmArgument>-Xmx512m</jvmArgument> </jvmArguments> </dex> </configuration> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>org.apache.cordova</groupId> <artifactId>phonegap</artifactId> <version>1.9.0</version> </dependency> <dependency> <groupId>com.google.android</groupId> <artifactId>android</artifactId> <version>4.1.1.4</version> <scope>provided</scope> </dependency> </dependencies> </project>
La solución para evitar este error, es incluir la siguiente línea en la configuración del plugin (dentro de las etiquetas <configuration></configuration>
):
<attachJar>auto</attachJar>