I have several problems with my android project written using maven plugin.
The first issue is that even if the project builds fine with maven, i cannot launch it. The message that i get in console is the following:
Dx
trouble writing output: already prepared
[2014-09-15 11:13:31 - easyex] Dx
trouble processing "javax/xml/namespace/QName.class":
Ill-advised or mistaken usage of a core class (java.* or javax.*)
when not building a core library.
This is often due to inadvertently including a core library file
in your application's project, when using an IDE (such as
Eclipse). If you are sure you're not intentionally defining a
core class, then this is the most likely explanation of what's
going on.
However, you might actually be trying to define a class in a core
namespace, the source of which you may have taken, for example,
from a non-Android virtual machine project. This will most
assuredly not work. At a minimum, it jeopardizes the
compatibility of your app with future versions of the platform.
It is also often of questionable legality.
If you really intend to build a core library -- which is only
appropriate as part of creating a full virtual machine
distribution, as opposed to compiling an application -- then use
the "--core-library" option to suppress this error message.
If you go ahead and use "--core-library" but are in fact
building an application, then be forewarned that your application
will still fail to build or run, at some point. Please be
prepared for angry customers who find, for example, that your
application ceases to function once they upgrade their operating
system. You will be to blame for this problem.
If you are legitimately using some code that happens to be in a
core package, then the easiest safe alternative you have is to
repackage that code. That is, move the classes in question into
your own package namespace. This means that they will never be in
conflict with core system classes. JarJar is a tool that may help
you in this endeavor. If you find that you cannot do this, then
that is an indication that the path you are on will ultimately
lead to pain, suffering, grief, and lamentation.
[2014-09-15 11:13:31 - easyex] Dx 1 error; aborting
[2014-09-15 11:13:31 - easyex] Conversion to Dalvik format failed with error 1
I saw many question on SO about that problem but noone helped me.
To solve this problem i tried to:
This is my pom:
<?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.italialinux</groupId>
<artifactId>easyex</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>apk</packaging>
<name>easyex</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<platform.version>4.1.1.4</platform.version>
<android.api.level>17</android.api.level>
<android.plugin.version>3.8.2</android.plugin.version>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>
<repositories>
<repository>
<id>repo</id>
<url>file://${project.basedir}/repo</url>
<releases>
<enabled>true</enabled>
<checksumPolicy>ignore</checksumPolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.italialinux</groupId>
<artifactId>android-support-v4</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>${platform.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>${android.plugin.version}</version>
<configuration>
<dex>
<coreLibrary>true</coreLibrary>
</dex>
<sdk>
<path>${env.ANDROID_HOME}</path>
<platform>${android.api.level}</platform>
</sdk>
<deleteConflictingFiles>true</deleteConflictingFiles>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
<extensions>true</extensions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself. -->
<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.8.2,)
</versionRange>
<goals>
<goal>consume-aar</goal>
<goal>
generate-sources
</goal>
<goal>proguard</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Please note that i created a custom repository for android-support-v4 because it seems that the version available online in the default repository is not updated and it lacks some features that are available in the latest version.
Do you have any idea on how to solve this issue? I'm not sure if it is Eclipse Luna related, but i have the same project configured in another eclipse (Kepler) and it works fine.
To sum up i have the following problems:
EDIT
I still have the problem. BUt i add more details. If i compare the Maven Dependencies Library on my Kepler Installation and the one in Luna i can see that in the luna Library there are all jar that are in the dependencies list of android package (http://mvnrepository.com/artifact/com.google.android/android/4.1.1.4). while in Kepler i can see only android-support-v4 library.
In kepler installation i can select Maven Dependencies and inlcude them in the Build Path (in that way i can have the android support v4 libraries), but using luna, if i include Maven Dependencies i have the error above.
EDIT 2 Another difference between kepler and luna is that the first has installed m2e for eclipse version 1.4, and the second has installed the version 1.5.
I spent many days investigating that problem, and I found what is the problem, and two possible solutions.
First of all: What is causing that problem?
The m2e-android plugin is still not working well with m2e plugin version 1.5. This is well documented here:
https://github.com/rgladwell/m2e-android/issues/224
There are two possible solutions to this problem:
The first is to build m2e-android using the code in github not released yet (That seems to fix the issue). I didn't try that solution, but if you want here is explained how to build the plugin from sources:
https://github.com/rtack/m2e-android/tree/m2e-1.5
Use m2e plugin 1.4.* But you cannot use that plugin using eclipse luna. So what you need to do is replac luna with kepler and install an older version of that plugin.
Since through the marketplace you can only the latest version, you must install it manually using Install New Software.
Go to Help -> Install New Software and add a new repository with the following URL:
http://download.eclipse.org/technology/m2e/releases/1.4/1.4.1.20140328-1905