Why are my resources suddenly unresolved in my Android project?
Eclipse is complaining about my Android project saying all my references to resources are unresolved, even though R.java does exist. For example:
signin_btn=(Button)findViewById(R.id.signin_btn); signin_btn.setOnClickListener(this);
I definately have si开发者_开发百科gnin_btn defined in my resources. Dont know why Eclipse is not seeing my R class anymore. How to fix?
The thing that happens to me once in a while is that Eclipse decides to "help" me by adding the following statement to the top of the source file:
import android.R;
This means that all non-absolute references will now be matched against the Android built-in resources, instead of your own. Something like "R.id.layout" is now supposed to be in "android.R.id.layout" and not in "com.mydomain.myproject.R.id.layout". Just remove the line.
It happens to me, this is what I think happens:
Whatever process generates R.java starts at the top of your resources and works to the bottom. If it encounters an error somewhere, it just stops... leaving whatever resources haven't been added to R.java out. This is why some of them will say "unresolved", and others will be fine.
It seems that every time you save a file in your project, it regenerates R.java (maybe it's just the files in res/), so you probably fixed whatever the generator broke on, and when you saved AndroidManifest.xml, it regenerated R.java.
精彩评论