I import a project to Android Studio , but the R.java is always empty.
public final class R {
}
I have tried:
I found my solution here. In short make sure not only the Eclipse plugin(if you are using eclipse) is updated. Also ensure that the Android SDK Tools, the SDK platform-tools and the SDK Build-tools are updated. After this restart your machine.
Best Solution for android studio Users :
Goto : Menu tab - > Build - > Rebuild Project
after rebuild Proj. your R.Java file problem will be solve automatically ..
So, this is the latest solution if anyone get's stuck like I did today especially, for R.Java
file.
If you have lost the count of:
- Clean Project
- Rebuild Project
- Invalidate Caches / Restart
- deleted .gradle folder
- deleted .idea folder
- deleted app/build/generated folder
- checked your xml files
- checked your drawables and strings
then try this:
check your classpath dependency in your Project Gradle Scripts and if it's, this:
classpath 'com.android.tools.build:gradle:3.3.2'
then downgrade it to, this:
classpath 'com.android.tools.build:gradle:3.2.1'
I failed even if I tried to update the SDK tools as mentioned here.
Here is how I solved the problem (for the library projects imported).
In File -> Project Structure -> Modules, I removed the problematic projects, and added them again by selecting New Module -> Android Library Module.
After rebuilding the project, I got all the R.java
files back.
I had a similar problem within my project using Android Studio 1.5.1. For me, bulding the project from command line by using following command resolved the problem:
gradle assembleRelease