Pregunta

I cleaned my project and now I get a "R cannot be resolved to a variable." It was fine before I cleaned it.

I have tried cleaning it again, building the project again, creating a new project and copying all my files over, and I've gone to the Android SDK Manager and installed all the "Android SDK Build-tools" to Install all the options like the other stackoverflow posts have mentioned: enter image description here

Can anyone suggest anything?

enter image description here

The above picture shows my generated files and lack of an R.java file.

When I check the Problems

The above picture shows my problems log.

¿Fue útil?

Solución

Make sure R is in the same package as the file where you want to call it from. (or import the package in the source file)

To change the package of the R file open your App Manifest file and change packge="" to the same package as where your source files are in.

eclipse-image

Otros consejos

maybe you import take other thing

See package main import in your code should be like this example:

import com.mypackageprincipal.R;

other import of R delete only should exist it

and after clean and build your project

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top