8

I'm using AndroidAnnotations in an Android Studio gradle project. I currently get error output from AA during compilation that says:

cannot find symbol class MyActivity_

The error output does not prevent building the application - its not really a compile error because the class is there, it seems that it is just an unfortunate timing issue with the compilation process.

Is there anything I can do to avoid these false-positive errors from AA? When there are "fake" errors shown every time I compile, its very easy to miss the real errors.

SuperDeclarative
  • 1,609
  • 4
  • 18
  • 32
  • What do you mean by compilation? "making" the project or the ide static analysis? Do you use the latest AS? – WonderCsabo Oct 25 '14 at 11:13
  • "Make Project" and "Rebuild Project" both generate the error in the build output. It is not an IDE check. I am using AA v3.1 – SuperDeclarative Oct 26 '14 at 17:03
  • Does it work from command line? – WonderCsabo Oct 26 '14 at 18:32
  • When I assembleDebug at the command line, I do not see the error output. But as I mentioned in the question, even when the error is displayed in Android Studio, it doesn't prevent the build, it just makes me pay a lot more attention to the build output to make sure there are no real build errors to worry about. – SuperDeclarative Oct 28 '14 at 15:46
  • Please try out our [example](https://github.com/excilys/androidannotations/tree/develop/examples/gradle) project. Does it produce the same errors in the IDE? Also it can produce these errors if the project was not built, yet, since the generated classes are not present that time. You have to make the project with the IDE, make sure the classes are generated, and IntelliJ indexed them so the editor can pick them up. – WonderCsabo Oct 28 '14 at 20:42

3 Answers3

7

I had same error. To solve it I have revert my last changes and it has worked again. I think it was either wrong optimized import(you must import generated classes eg. xxx_) or I injected layout by id what was not existed in the layout xml

Update

I figured it. My problem was what I had use private mofidier instead of proteced in

@ViewById(R.id.list) 
private ListView list;
Murtaza Khursheed Hussain
  • 15,176
  • 7
  • 58
  • 83
Evgeny
  • 71
  • 1
  • 2
  • Thank you for this answer. This made me look at my changes more closely, and I had accidentally used `@Bean` instead of `@Pref` somewhere in my code. Frustrating. The errors/warnings being thrown weren't very helpful. Although, in all fairness, there technically was one about me using `@Bean` and my Prefs_ file not being an `EBean` so I should have realized what the issue was. I have so many annotated classes that the error I needed got buried amidst lots of cannot find symbol errors. Hopefully the AA folks can figure out a way to better highlight the underlying issue when a build fails. – Ben Kane Jun 02 '15 at 11:41
  • This answer gave me a hint as to what happened which is that I used `AfterViews` on a method with wrong number of parameters (1 instead of 0) – smac89 Aug 23 '15 at 09:33
1

Try to see if you missed to fix some errors in the class MainActivity or in someone of his Bean member that you have annoted.

Qu4sar
  • 64
  • 2
  • 11
1

The problem doesn't have to be in MainActivty, but it is probably because of a private modifier which is used with Android Anotations (in injection, method declaration etc) somewhere in your code

Leo DroidCoder
  • 14,527
  • 4
  • 62
  • 54