Duplicate classes R & BuildConfig after "Reimport All Maven Projects"

android, intellij-idea, maven

Solution

According to the reply of Sven Strohschein at http://youtrack.jetbrains.com/issue/IDEA-94901 you can try to:

- Delete the "gen", "target" and "out" folders

- Revert the changes within the "ipr" and "iml" files (or just delete them all, maybe even .idea folder)

- Start IntelliJ 12

- Open the pom file

- Right click -> "Maven" -> "Reimport"

- "Build" -> "Rebuild project"

Works fo me.

Problem

We are building our Android projects with Maven and IntelliJ IDEA. Sometimes we must execute "Reimport All Maven Projects", e.g. to update dependencies. The problem with that is that it always messes up the source folders for resources: all modules get "gen" and "target/generated-source/r" which seems to be the cause for the duplicates. So after reimporting, we need to manually delete one of those (usually the "gen" folder). Of course, we want to avoid this step. We tried several settings for the Android facet, but no luck so far. So, how can we configure IntelliJ to do a proper Maven reimport that just works?

Original source