I import a project to Android Studio , but the R.java is always empty.
public final class R {
}
I have tried:
- Make project,make module, remake, etc.
- Project Setting-modules-sources, then add src and gen as my source folder.
But they are not take effect.
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
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.
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:
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.
If you are facing this problem in a specific module in your project, you could try opening just that module as a project and then build it. This worked for me. It was failing to generate the R file for the module when I was trying to re-build the entire project.
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.