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

We are building our Android projects with Maven and IntelliJ IDEA. Sometimes we have to run "Reimport All Maven Projects", for example. to update dependencies. The problem is that he always messed up the source folders for resources: all modules get "gen" and "target / generated-source / r", which apparently cause duplicates. Therefore, after re-importing, we need to manually delete one of them (usually this is the "gen" folder). Of course, we want to avoid this step. We tried several settings for the Android facets, but so far no luck.

So, how can we configure IntelliJ to execute the correct Maven reimport, which only works?

+6
source share
3 answers

According to Sven Stroshin’s answer at http://youtrack.jetbrains.com/issue/IDEA-94901 you can try:

  • Delete the gen, target, and out folders
  • Discard changes in the ipr and iml files (or simply delete them, possibly even in the .idea folder)
  • Launch IntelliJ 12
  • Open the pom file
  • Right click -> "Maven" -> "Reimport"
  • "Build" β†’ "Restructuring Project"

It works for me.

+2
source

After IDEA detects and adds an alt facet to the module, it will start generating the gen folder in the usual place, but the maven-android-plugin generate its own file in the target directory.

You need to say that IDEA places the generated files in the same place where the maven-android-plugin creates them.

First, use the facet model parameters modulo and check the possibility of using the Maven target instead of generating it yourself:

enter image description here

Then go to the module settings and set the output path to the same as Maven, which is located in the target directory:

enter image description here

Delete the gen directories, Do mvn clean , to delete all unnecessary files.

+1
source

From your description above, I assume that your project structure is different from the default maven. See Introduction to POM . But I think android android: generate-sources is more interesting if you changed the asset directory, etc.

Example:

 <sourceDirectory>${basedir}/src</sourceDirectory> <outputDirectory>${basedir}/target/classes</outputDirectory> 
0
source

Source: https://habr.com/ru/post/949753/


All Articles