Maven and apklib: Duplicated file error

31 05 2014

The maven build error occurred when I had two Android projects: the one is apklib and the second one that is the actual application (the apk file) that uses apklib.

The error is saying that apk project contains duplicated and files under target directory. The first file comes from apk project, and the second one from apklib.

There are two solutions for this problem:

Solution 1: Update android-maven-plugin

Update android-maven-plugin to the newest version (currently it is 3.8.2 or 3.9.0 release candidate to be checked here) where this bug is fixed.

The problem is that for example the 3.8.2 release is supporting only maven in version 3.1.1. no lower nor higher version will work. This would require downgrading maven on few machines so I decided to use another solution.

Solution 2: Remove conflicting files during apklib build with maven ant plugin

I’ve found solution on the Internet to remove duplicated files from the apklib target with ant plugin during build. The maven-antrun-plugin can do it. I added these lines to apklib pom.xml:

					<delete dir="${project.basedir}/gen" />

Then rebuild the apklib project and apk after that. This works!

Eclipse problems with ant plugin

Ant plugin is not recognized by eclipse maven m2e connector and eclipse displays errors. the project still can be built with either maven or eclipse build, but the error is visible on the pom.xml.

Then with plugin management in apklib you can force eclipse to ignore the ant plugin command. It does not affect maven build, just the eclipse compilation.

You can do it by eclipse quick fix or by adding manually plugin management directive to apklib’s pom.xml:

	<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->



Give Your feedback:

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: