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?
After IDEA detects and adds Android facet to module, it would start generating
gen
folder at usual place, butmaven-android-plugin
generates its own undertarget
directory.You need to tell IDEA to place generated files at same place where
maven-android-plugin
creates them.First, use module's android facet settings and check the option to use Maven goal instead of generating by itself:
Then, go to module's settings and set output path same as Maven's, which is
target
directory:Delete
gen
directories, Domvn clean
to clear all unnecessary files.From your description above I guess that your project structure differs from the maven default. See Introduction to the POM. But I think the android android:generate-sources is more interesting if you have changed the assets directory etc.
Example:
According to the reply of Sven Strohschein at http://youtrack.jetbrains.com/issue/IDEA-94901 you can try to:
Works fo me.