I import a project to Android Studio , but the R.java is always empty.
public final class R {
}
I have tried:
I will answer the question even though it has been a long time since it was thrown, just in case someone else get to it.
Tested on Android Studio ONLY (but I guess it could work for Eclipse as well) :
Check your build/source/r folder. In there, you should find some directories labelled under the name of your gradle build name (default : debug). Verify that the name of the package associated with R is the one you want.
I know this trick solves the problem of switching namespace, because Android Studio (or Gradle I don't know who is responsible for that) seems not to regenerate it in that case.
I haven't tried it when importing a project from Eclipse though.
Did you follow steps here? First update your Eclipse ADT plugin, then export project and the import in Android Studio.
http://developer.android.com/sdk/installing/migrate.html
Check your project package! I had brought some classes over from another project and did not notice the subtle change in the package name. See top of your AndroidManifest.xml
Go to File → Settings → Editor → Auto Import and at java tab you should have:
Insert imports on paste: ASK.
If you have import for ALL, then Android Studio import other file.
As for me, the problem was in this superfluous line:
import android.R;
Go to Menu-Tab -> Project -> Build -> Automatically(check this option). and than reopen a new project.