I import a project to Android Studio , but the R.java is always empty.
public final class R {
}
I have tried:
When I was trying to add another flavour
I face same situation.
I found in one of post and I gave successful try and it work. Following I did: File -> Invalidate Cached/Restart.
File->Invalide Cahces / Restart
I had a similar problem in a large multi-module project with many dependencies among the modules. What worked for me, was to attempt to build separately from command line all the modules that failed to build within Android Studio. That gave me indications on resources missing in each project. From the project level in my console I did:
$ cd moduleName
$ ../gradlew assembleDebug
This provided me with a number of 'No resource found that matches the given name' errors, that weren't shown before, when I build the project as a whole.
I had this problem after update gradle...
There are several reasons that causes the project not to be built:
1-Unknown error in drawable or xml files
2-Update gradle or libraries and etc ...
Solution :
1-Clean and rebuild project
2-Delete .idea and build folders in project file(shown in picture) then goto "File/Invalidate catch-restart"
3-Roll back to previous gradle version and libraries.
I had a lot of problems exporting a project from Eclipse (assuming that is where you are exporting from). It was much easier for me to create a new project in Android Studio, then copy over the java files, xml files, layout directories, etc, and the AndroidManifest, into the appropriate location in the new project.
If you already have an R.java file for your project, you could try just copying it over to the new project. In Android Studio the R.java file seems to reside in build/source/r/debug/your-package-name/
Had the same problem and solved it by:
Project/Module/build/source/r/debug/package/R.java
Probably it was even there before the project was build, but I didn't test that.
I hope this was helpful, even though the answer comes a bit late and by now the bug with the
Settings->Compiler->[ ] Use external build
should be fixed afaik ;-)