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
Goto File -> Settings -> Compiler now check use external build
then rebuild 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.
File -> invalidate caches
then
Restart application
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.
android {
buildToolsVersion "22.0.1"
..
..
..
}
In my case I had an Activity file imported from Eclipse that had the line:
import android.R;
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.
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.