I extracted a bunch of functionality from my application to the library. The problem is that I would like to use library classes in both production code and tests. The problem is that my application, my library and test code are separate modules, therefore both the application code and the test code must depend on the library. When I try to compile a test module, I get the following error:
UNEXPECTED TOP-LEVEL EXCEPTION: java.lang.IllegalArgumentException: already added: (some class)
This is cryptic, but he is trying to say that I tried to add the same class to the .dex file more than once. This is not too surprising, since the test code depends on the library and application code at compile time, which also depends on the library at compile time. How to configure my dependencies (or change the code) to avoid this?
NOTE. I use IntelliJ IDEA 10.5 CE, so I use their terminology, but I think the problem is at least conceptually IDE agnostic.
source share