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 has a j in a little red circle on it. And in my source files, I get "cannot resolve symbol R" wherever I have a reference to a resource, e.g. "R.layout.account_list" etc.
I have never used Intellij before. Would appreciate any help as there obviously aren't many answer yet about Android Studio. Thanks!
then
The solution posted by https://stackoverflow.com/users/1373278/hoss above worked for me. I am reproducing it here because I cannot yet comment on hoss' post:
Remove
import android.R;
from your activity file in question.My setup:
Android Studio 1.2.2
Exported project from one Mac to Git (everything was working). I then imported the project on another Mac from Git. Thats when it stopped resolving the resource files.
I tried everything on this thread:
Nothing worked except removing
import android.R;
from my activity java file.To avoid this issue in the future add
.idea
folder to your.gitignore
file. There is a nice plugin from git for gitignore in Android Studio. Install this plugin and right click in.idea > Add to .gitignore
None of the answers on the web so far have helped. Build > Make Project did not work for me. For me it was as simple as choosing this other option (on Android Studio 1.3.1):
Build > Make Module 'module name'
At first check if there is import android.R; in top of your class this happens when auto import in enable in android studio.
after that comment all lines of your code that you use R variable (you can comment entire class or ...) then run application it regenerates R variable and you can uncomment your code.
I hit this issue with intellij 2016.1 because I had set the generated sources to go to a directory that wasn't in the base project directory.
For example, in the Android facet, under "Generated Sources" I had:
Directory for generated files: <project dir>/target/intellij-gen
When I changed this to
<project dir>/gen
the problem went away.Likewise when I then changed it to
<project dir>/gen2
the problem also went away - but I had to do a deep clean to get it to compile again by doing:rm -rf ~/.IdeaIC2016.1/system/compile-server/<project>_<hash>
and deleting all the generated directories and
target
dir.Follow the five steps below:
<uses-permission android:name="android.permission.VIBRATE"></uses-permission>
)I have had the same problem but after all the steps it's work for me.