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

我只是一个虾纸丫 提交于 2019-12-07 04:08:32

问题


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.

回答1:


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.




回答2:


This seems to be working for me:

Let the ADT keep gen as a source folder, but change the output folder for that source folder to be /target/classes.

I can build in both eclipse and using maven from the command line, and I don't get duplicate R class problems in either case. Essentially, Eclipse generates the R.java file in /gen, while maven generates it in /target/generated-sources/r, but both builds put the R.class file under /target/classes.

Note: at one point I had added /gen as an additional source directory in my pom.xml using build-helper-maven-plugin, and I had to remove that.



来源:https://stackoverflow.com/questions/10091226/change-output-folder-for-android-r-java-in-eclipse-when-using-maven

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!