I'm trying the new Android Studio. I've exported a project from eclipse, using the build gradle option. I've then imported it in Android Studio. The R.java file under gen has a j in a little red circle on it. And in my source files, I get "cannot resolve symbol R" wherever I have a reference to a resource, e.g. "R.layout.account_list" etc.
I have never used Intellij before. Would appreciate any help as there obviously aren't many answer yet about Android Studio. Thanks!
In my case I had an Activity file imported from Eclipse that had the line:
So all of my R classes were resolving to the SDK, as soon as I commented out that line everything compiled correctly to my package. I only noticed the issue when I was moving the project from my Mac to my Windows machine.
I was also facing the same issue and I went through lot of answer on stackoverflow. Then i found one solution which help me resolve this issue.
Check package name in AndroidManifest.xml file. I forgot to change it while copy pasting another project into new project.
The solution is to open project structure window. [by press command+; on mac ox s. i don't what's the key shortcut for other platforms. you should be able to find it under "File" menu.] and click "Modules" under "Project settings" section, then your project is revealed, finally mark the generated R.java as Sources.
I am using Intellij idea 14.0 CE. The generated R.java is located at build/generated/source/r/debug/com/example/xxx
Really not easy to find for the first time.
Here's what worked for me in IntelliJ (Not Studio), in addition to the replies presented above:
You need to attach an Android facet to an existing Android module. To do this, select the module from the module list in 'Module Settings', hit the '+' button on top and select 'Android'. See https://www.jetbrains.com/idea/webhelp/enabling-android-support.html.
check the build tools version in build.gradle(for module app). Then go to android sdk manager see if the version is installed if not install it or change the build tools version to the one which is installed like below.
Had this error when importing project from Eclipse. The reason was some of the xml files had errors. Check ALL your XML files for errors. Including androidmanifest.xml, and values, themes, styles, layouts folders, etc. Warnings in xml are ok, but errors will generate this error.
Afterwards, do a Clean Project and rebuild.