Reputation: 275
I am brand new to android development and i am working with IntelliJ Idea 12. Everything is set up correctly but one problem i am facing is that my R.java file inside gen folder does not have the code that should have been there.I think this code should have been auto generated but it's not present there. Here are the links on on what my project structure looks like:
I could not post more than two links, so here is the link to gallery: http://postimage.org/gallery/19189wei/
It contains my string.xml , main.xml , R.java , HaikuDisplay.java So i wanted to know where's the problem?
Upvotes: 11
Views: 7636
Reputation: 21
I have the same problem with Android Maven project. My solution was that I look into Project History and find that my Manifest.xml file was somehow modified and paths to files was changed, but GOD knows that I did not make that changes. So I just revert this changes and rebuild project.
Upvotes: 0
Reputation: 67
I found this too, may be it is because the IDE wants to prevent you from editing the R.java file by mistake.
Upvotes: 0
Reputation: 100288
Removing auto-added import android.R;
from top of the file worked for me.
Upvotes: 0
Reputation: 635
Check your AndroidManifest.xml file. Idea 12 put two element under , there can be only one. Remove which ever you want, rebuild.
Additionally you can check the package value in manifest element. Make sure it corresponds to your project. Idea 12 generated the following for my project, which has com.awesome.skynetclient as root package:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.exeample.SkynetClient"
android:versionCode="1"
android:versionName="1.0">
Upvotes: 2
Reputation: 147
I have the same problem with idea 12 (and there were no such problem in idea 11). To fix it you may need to check the following:
After that idea will find, that there is many xml's in layout folder, and will know about all ids, xmls and strings.
But R.java file will still be empty, gen folder will not contain anything more then empty BuildConfig.java file, and there will be no other R.java files, that contains all this constants.
It looks like idea 12 as opposed to idea 11 store its generated R.java constants in project folder (.idea), and if you are using 'pom.xml' as project description - you will need to check all this points again after reloading pom.xml file.
Upvotes: 3
Reputation: 4822
I wouldn't bother looking at the R file - mine is empty as well and it doesn't matter. Try type R. and see what's available. If you're not setting your stuff, make sure you're not Importing Android.R in your imports - that will override your R and use the one in the SDK directory. Hope that helps.
Upvotes: 3