Reputation: 4266
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 :-)
Upvotes: 0
Views: 7237
Reputation: 708
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
Upvotes: 0
Reputation: 31
go to properties -> go to android - > change project build target this might will help. it worked for me
Upvotes: 3
Reputation: 1453
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.
Upvotes: 0
Reputation: 13588
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.
Upvotes: 0
Reputation: 4266
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)
Upvotes: 0
Reputation: 41126
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.
Upvotes: 0
Reputation: 1746
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.
Upvotes: 0
Reputation: 6972
I have the same problem. Please, check your SDK location in Window-->Preferences-->Android
Hope, it help you!
Upvotes: 0