R cannot be resolved - Android error 2 first one wasn't enough
-
04-12-2019 - |
Question
System:
Ubuntu 11.04 (up to date) Eclipse SDK - Version: 3.7.1 Android Development Toolkit Version: 16.0.1.v201112150204-238534
PhoneGap 1.3.0 PhoneGap Facebook Connect Plugin
Just was putting a little phone gap project and the R connot be resolved..
This is what i tried:
Deleted All my android projects: Restarted... Started new project..
Tried Clean... Rebuild...
REMOVED all import R attempts from auto orgnize...
Made sure correct xml file name are lowercase and changes are correct.. like i said new project
Deleted auto generated files so they could be rebuilt...
This is the code that is erroring...
Drawable crossDrawable = getContext().getResources().getDrawable(R.drawable.close);
mCrossImage.setImageDrawable(crossDrawable);
/* 'x' should not be visible while webview is loading
* make it visible only after webview has fully loaded
*/
mCrossImage.setVisibility(View.INVISIBLE);
I made sure and updated everything... and looked for bug fixes..
I'm stumped i usally work though stuff (because thats how you learn) but my head hurts...
Help me out, Thanks, Roger
Solution
Check if any of your xml file is having error,if yes then correct xml then clean your project and then see.
then also error persists then check your installation if its proper or not then try running the project.
OTHER TIPS
This could help someone save hours of time... on FbDialog.java
you must add the following line on the beginning:
import com.package.your.R;
(or whatever is your android package so that your R.java
will be imported to FbDialog.java
)
Instead of
Drawable crossDrawable = getContext().getResources().getDrawable(com.yourpackagename.R.drawable.close);
I added
int id = getContext().getResources().getIdentifier("close", "drawable", getContext().getPackageName());
Drawable crossDrawable = getContext().getResources().getDrawable(id);