"R cannot be resolved by a variable" error disappears after creating a project

I get the error message "R could not be resolved to a variable". I read another question on this issue, and it says to update the Android build tools so that the error goes away, but that doesn't fix it. But for some reason, the error goes away when I build a project.

What's going on here?

+4
source share
5 answers

I found this to happen with a broken layout. No need to worry. I try to give you a solution:

Decision:

  • , R. . XML . - ADK , R .

  • - - android.R , .

  • → .. R BuildConfig.

  • , . , → → .

, .

:

  • /gen/

:

  • → Android → .

*.properties( ) , .

> a > Android.

" " "" . AndroidManifest.xml. , 17 AndroidManifest, , - Android 4.2. X , , . , .

, R

  • , xml .

  • XML , /res/

  • : /layout/ /values ​​/, .

  • AndroidManifest.xml, , , AndroidManifest.xml.

  • , Android SDK Build-tools. Window- > Android SDK Manager- > - > Android SDK Build-tools

  • , Android SDK Tools Android SDK Platform-tools Android ASK Build-tools. .

:

  • /gen/- > ... → R.java - > "".. , , .

, .:)

+5

Build Automically eclipse Project?

+1

,

  • import android.R;
  • .
0

, Eclipse 10 ...

, .

, , / Android.

1. .

2. ..

3.after 5 . .

1. -- - -

2.r-

, 2

1. Cut and paste src (.java) (xml layout),

2. Build Your Project in New Work Space..

3. import android.R; java ..

Follow this procedure .. So, this error will no longer be.

0
source

Are you importing an android.R file or its own project? you are mistaken in your xml files. check your xm lfiles.

Are you sure your own R.java file has been created? Errors in your xml views can cause R.java to not be generated. Browse the view files and make sure all xml is correct!

0
source

Source: https://habr.com/ru/post/1525553/


All Articles