0

I just imported an old project into Eclipse (the newest one, I've upgraded), and I have a lot of

"R cannot be resolved to a variable" When I call it... (for example R.layout.tab, ...)

So I clean my project, I tried to use import Android.R, I checked my xml files, ... but nothing sounds wrong except some warnings in one xml:

"Hardcoded string "Login", should use @string ressource, followed by "This text field does not specify an inputType or a hint" for there lines :

<TextView android:id="@+id/logintext" android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:text="Login" />
<EditText android:id="@+id/login" android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:background="@android:drawable/editbox_background" />

I don't understand why those lines could affect all the R.java but... it is the only warnings that there is in the R...

How can I modify those lines to have a clean code?

Thanks for your attention and to help me :-)

Hiral Vadodaria
  • 19,158
  • 5
  • 39
  • 56
clement
  • 4,204
  • 10
  • 65
  • 133

8 Answers8

3

go to properties -> go to android - > change project build target this might will help. it worked for me

0

Important. After you have fixed any errors in your manifest file and your XML files be sure to click on Project=>Build All.

Everytime I opened the project it still had the same error. Only when I did a build all did it disappear.

karmafunk
  • 1,453
  • 12
  • 20
0

1) Check your xml files,there may be any error. 2) Check your manifest for errors. 3) Do not import android.R. 4) Go to window in menu bar and click show view.Under show view select problems.Below the editor,window will be displayed.check the errors and solve the error. 5) Clean and import R

anjaneya
  • 708
  • 9
  • 11
0

I have the same problem. Please, check your SDK location in Window-->Preferences-->Android

Hope, it help you!

ihrupin
  • 6,932
  • 2
  • 31
  • 47
  • @hru : Thanks. I checked it and there is a huge list of differents SDK. I selected one ... I cleaned the project, and all is again wrong :-/ – clement Dec 19 '11 at 15:34
0

Go to project explorer and see if gen/.../R.java is generated or not, most likely not.

So your project is failed during pre-processing. The two warnings are safe to ignore.

pinxue
  • 1,736
  • 12
  • 17
  • Is there any thing with red X in project explorer, like some xml? – pinxue Dec 19 '11 at 15:43
  • Tnahks ! All the red is in the src ( the R ...), and there is only warnings in the res/layout folder (cfr the code in the initial post) ... – clement Dec 19 '11 at 16:05
  • Try to fix them then. Maybe you have changed some setting or installed some lint tool to treat warning as error which prevent R.java from generated. – pinxue Dec 19 '11 at 16:12
  • OK, I tried to run an other project but the same issue, what could cause that error??? – clement Dec 19 '11 at 16:34
  • Hard to guess. Is Eclipse able to write gen directory? You may run "android update project" in your project to get build.xml and then run "ant -v debug" to see building details. Maybe it will give some useful information. – pinxue Dec 19 '11 at 23:48
0

There are many possible reason that may cause ADT plugin refuse to generate gen folder with R.java when fresh import project, As you have already tried ihrupin and pinxue's suggestion and doesn't work, check out this similar SO question here to see if the answers help.

Community
  • 1
  • 1
yorkw
  • 40,926
  • 10
  • 117
  • 130
0

I Re-download my SDK, I reboot my machine and it has fixed the solution (except that now I've a japanese keyboard hum... an other problem)

clement
  • 4,204
  • 10
  • 65
  • 133
0

Remove all import android.R statements and clean the project. Also check whether all the drawables and layouts are present r not?Also check the java version(rightclick on project>properties>java build path), if it is exactly same as the original one. If it doesnt work, just redownload android sdk.

Seshu Vinay
  • 13,560
  • 9
  • 60
  • 109