Tag Archives: aop

AOP on Android – Duplicate files at the same path inside the APK

This post won’t deal with Android/aop configuration, for more information on the subject  I would recommend reading this one.

I’ve been struggling all day to resolve an annoying issue I had with aspectJ, Android and Maven.

When compiling java class files to dex the dex compiler packs everything under the same file, classes.dex. During this process if for any reason you have files with the same name that exist under the same path then you’ll have the dreadful exception “Duplicate files at  the same path inside the APK”.

Whenever using the aspectj maven plugin a configuration file named builddef.lst is created and is placed in the project build output directory. It seems that this is the culprit for duplicate file exception. One way to solve it is to use argumentFileName parameter under the plugin configuration:

                <goal>compile</goal>    <!-- use this goal to weave all your main classes -->
        <argumentFileName>trace.lst</argumentFileName> <!-- Set the name here -->

The problem is the need to give a different name for each library that uses aop, annoying to the say the least.
If only we could remove the configuration file from the final jar/apk, guess what…you can. The jar plugin comes to the rescue:


We are excluding trace.lst and avoiding the problem from the start. Make sure to add this plugin under the build section of your pom file for each jar/apk that uses aop and you are done.


Leave a comment

Filed under Building