Intellij IDEA 12: Duplicate class error for generated classes #423

Closed
a85 opened this Issue Dec 6, 2012 · 23 comments

Projects

None yet

8 participants

@a85
a85 commented Dec 6, 2012

I just upgraded to Intellij IDEA 12 Community Edition. On compiling my project I have started getting a duplicate class error on all annotated classes. For ex:

java: activities/BaseMapActivity_.java:16: duplicate class: activities.BaseMapActivity_

I do not get the warning as mentioned in this report on the JetBrains bug tracker: http://youtrack.jetbrains.com/issue/IDEA-94150. I removed the generated source folder from the source path but no luck. I get a no symbol found error then.

@pyricau
Contributor
pyricau commented Dec 6, 2012

Do you use Maven ?

@a85
a85 commented Dec 6, 2012

Nope. Not at the moment.

@a85
a85 commented Dec 6, 2012

Btw. I haven't switched to 2.7 yet. Still on 2.6.

@pyricau
Contributor
pyricau commented Dec 6, 2012

This issue may be resolved by 2.7, it would be nice if you could try to use it :) . At least as a test.

@a85
a85 commented Dec 6, 2012

Sure. Back on Idea 11 to get a minor release out. Will give IDEA 12 a shot
with 2.7 in a couple of days.

On Thu, Dec 6, 2012 at 6:10 PM, Pierre-Yves Ricau
notifications@github.comwrote:

This issue may be resolved by 2.7, it would be nice if you could try to
use it :) . At least as a test.


Reply to this email directly or view it on GitHubhttps://github.com/excilys/androidannotations/issues/423#issuecomment-11083879.

@krischik
krischik commented Dec 6, 2012

Hate to say: But I have the same problem with IDEA 11 as well. With «mvn clean» as a good workaround.

Strange thing: I never actually found the 2nd class file.

@a85
a85 commented Dec 9, 2012

Ok. Tried with Idea 12 again and AA 2.7. These are my steps:

  1. Go to Settings > Annotation Processors
  2. Enable annotation processing
  3. Add androidannotations-2.7.jar in processor path
  4. Production sources directory: aa-gen
  5. Test sources directory: aa-gen-tests
  6. Store generated sources relative to: Module content root/Module output directory (tried both)
  7. Include androidannotations-api-2.7.jar in the main module as a dependency
  8. Add aa-gen as a Source in the module settings. (tried compiling without it)
  9. Re-build project

I get a "cannot find symbol" error for all AA classes. The aa-gen folder is empty.

Problem is that I don't have maven set up with this project due to issues with library projects with NDK dependencies earlier. I can't use something like mvn clean.

Let me know if I am going wrong somewhere. This setup works with Idea 11 so am guessing something changed with Idea itself.

@ashokgelal

I can confirm this bug with AA 2.7, Idea 12 and Maven. mvn clean didn't help. This might sound silly but I got it working by removing the @EActivity annotation from the main (and removing _ from the activity name in AndroidManifest file). Ran it once, changed back to AA again. But then, if you rebuild, it breaks again. Weird.

@ashokgelal

Finally got it working! The problem is not with AA but with how you setup your sources directory. I spent a lot of hours setting up Android with Maven + ActionBarSherlock + Roboelectric + AndroidAnnotations with IntelliJ IDEA 12. I've written a long blog post (with code snippets and screenshots) on how to setup everything from scratch here - http://www.ashokgelal.com/2012/12/setting-up-intellij-idea-12-with-maven-actionbarsherlock-roboelectric-androidannotations/.

Hopefully, it will be useful for others.

@a85
a85 commented Dec 12, 2012

@ashokgelal Thanks! Looks great. I'll try setting up Maven here again.

If anyone has had success without using Maven, please let me know!

@Trikke
Trikke commented Dec 12, 2012

http://stackoverflow.com/questions/13832585/integrating-androidannotation-with-intellij-idea-12/13836308#13836308

i've also written up a small stackoverflow answer on this issue and my experiences (i'm not using maven, just AA and ActionBarSherlock + EventBus). The only problem I have is that everytime i change a source which uses AA, and just "run" my project (or first make my main module), is that it will crash because of an NPE (of an added @Bean) in a superclass of that edited source (which also uses AA). So i have to rebuild my entire project every time i want to test something. My main guess is that I don't see any AA output when I make my main module, so i guess AA is only run on a rebuild.

@ened
Contributor
ened commented Dec 19, 2012

See: http://youtrack.jetbrains.com/issue/IDEA-96797 & http://youtrack.jetbrains.com/issue/IDEA-96342

However I don't have success with either solution. Apparently the build system was replaced in v12.

@pyricau
Contributor
pyricau commented Dec 20, 2012

So, just to be clear : is the problem solved for everybody with this article : http://www.ashokgelal.com/2012/12/setting-up-intellij-idea-12-with-maven-actionbarsherlock-roboelectric-androidannotations/ ?

@ened
Contributor
ened commented Dec 20, 2012

Actually I just updated to IntelliJ 12.0.1 and that particular problem is gone. I'm able to compile now. @Trikke maybe you try to upgrade as well and let us know.

@a85
a85 commented Dec 20, 2012

@ened Great. I shall upgrade and give it a shot. Nothing else worked for me without Maven though.

@pyricau
Contributor
pyricau commented Dec 20, 2012

Hey guys, feel free to suggest any change to the Maven-IntellijIdea and IntelliJIDEA wiki pages.

I don't use IntelliJIDEA yet so I can't help much there for now. It's on my TODO list for next year though. I'm gonna work in an Android team that uses IDEA a lot so it's a good time to switch.

@ashokgelal

I'd be nice (and helpful for others) if you can add the link http://www.ashokgelal.com/2012/12/setting-up-intellij-idea-12-with-maven-actionbarsherlock-roboelectric-androidannotations/ to the IntelliJ + Maven wiki.

@a85
a85 commented Dec 20, 2012

@pyricau Upgrading to 12.0.1 works for me too. I believe this was the bug which has been fixed in IDEA: http://youtrack.jetbrains.com/issue/IDEA-96230#. No changes were required in the steps but I think it would be nice to mention that AA works with 12.0.1 in the wiki.

@pyricau
Contributor
pyricau commented Dec 22, 2012

Thanks guys!

@a85 a85 closed this Dec 24, 2012
@RomainPiel

I don't know if it's only me but I'm facing the same issue using IntelliJ 12.1.1. Downgrading to 12.0.4 fixes the issue. Any idea?

@ashokgelal

@RomainPiel I've seen this too. If you have followed my tutorial on http://www.ashokgelal.com/2012/12/setting-up-intellij-idea-12-with-maven-actionbarsherlock-roboelectric-androidannotations/, use aa for Production sources directory, and aa-test for Test sources directory. You probably want to delete the gen folder first as well as do a Rebuild after making above changes.

@RomainPiel

oh I missed that step, thanks man!

@cesards cesards referenced this issue in ManuelPeinado/RefreshActionItem May 19, 2013
Open

Problem compiling the project with IntelliJ IDEA 12 #4

@jjalonso

Im using regular 2.7.1 jars, and appear work fine now. describe here my instructions:

1.- Add androidannotations to /lib
2,- Add androidannotations-api to /libs and add it as library.
3.- Set the (1) androidannotations as processor in settings, mark content root, and use "gen" and "aa-tests"
4.- androidannotations-api must be with compile scope.

These steps works for me, before i was using gen/aa as folder, but fails sometimes with duplicate class, now with "gen" work fine, and i think that is not bad mix it with R and others.

Thanks alls for the tips!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment