Can't reference R class on Android Maven project
When rebuilding my project IntelliJ IDEA generates the updated R class, although I can't use it. Why?I need to use it to reference one of my activities from R.layout. Can you help me?I'm using IntelliJ IDEA 12.
请先登录再写评论。
Please provide more details. What do you mean by "can't use it"?
The main package for my project is br.com.remote, my Android Activities are inside the br.com.remote.activities package, then when I try to use R.menu.main_menu from one of the activities (the main_menu resource file exists) it can't find the R class inside the current package (br.com.remote.activities) and neither in the main package. It keeps trying to use the Android.R class which is not the one that I need.
Check if R class exists ( Navigate | Class ). If it does, try to type full reference like br.com.remote.R in your code.
It doesn't exist.
Coluld you please check following:
Go to Project Structure | Modules | choose Android facet to open facet settings. Then open "Compiler" tab. Is "Run 'process-resources' Maven task before Make" selected? I did manage to reproduce the problem in such case only.
Exactly what I needed.
Thank you
I've created a bug report in the tracker: http://youtrack.jetbrains.com/issue/IDEA-97686 , please vote. BTW if "external make" mode is enabled (by default in IDEA 12, it is) processing resources by Maven is not used anymore: R.java is generated by the IDE anyway.