I have the following directory structure within IntelliJ, which contains an Android library project:

java/com/example/base/AndroidManifest.xml
java/com/example/base/assets # contains Android assets
java/com/example/base/res    # contains Android resources
java/com/example/base/Base.java
java/com/example/base/base.iml

The base.iml contains the following:

<content url="file://$MODULE_DIR$">
  <sourceFolder url="file://$MODULE_DIR$"
                isTestSource="false"
                packagePrefix="com.example.base" />
  <sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" />
  <excludeFolder url="file://$MODULE_DIR$/res" />
</content>

When I build an Android application project that depends on my library project, I get an error:

[myapp] java.util.zip.ZipException: duplicate entry: res/drawable/image_shadow.9.png

In the Project Structure dialog, I configured Project compiler output to be an out directory under the root of my project. When I try to build my Android project, I noticed that copies of my Android resources end up under the out/production/base/com/example/base/res/ folder.

My hypothesis is that my Android resources are being treated like "normal" Java resources (the type you would load using Class.getResource()), which is why they are being copied to out/production, which in turn causes the duplicate entry exception that I am seeing.

Any idea if this is the case? If so, how can I prevent these files from being copied over? In Eclipse, the <classpathentry> element in the .classpath file has an excluding attribute that takes a glob pattern to prevent this sort of behavior.

Edit
Report