Search code examples
javaandroidmavenm2eclipseandroid-maven-plugin

Change output folder for Android R.java in Eclipse when using Maven


I have an android project setup using the maven-android plugin. This plugin adheres to maven output folders for the location of the R.java file (i.e. target/generated-sources/r).

However, when using this project in Eclipse, I can't configure aapt to rely on that folder.

Even if I manually go into the project properties and set up the folders manually, the ADT plugin goes in and resets just some of the settings (i.e. adds the /gen folder back as a source folder, and restores the output folder to /bin/classes instead of /target/classes), while leaving the maven /target/generated-sources/r folder and breaking the build of the project.

I would like to use the default Maven folder structure with the Eclipse ADT. Any ideas on how I can do this?

Thanks


Responding to the comments:

  • Yes, am using the m2e-android plugin.
  • Because ADT is still generating R.java in /gen, Eclipse is failing to compile if there still exists an R.java under target/generated-sources/r due to duplicated class definitions.

Solution

  • Unfortunately, the Android Connector for M2E does not support moving generated folders like the ADT gen folder to other directories. This is a restriction of the ADT, although there is a ticket to explore a way around this restriction:

    https://github.com/rgladwell/m2e-android/issues/68

    If you'd like to stay updated, please comment on this ticket.