Sori
Sori

Reputation: 35

Android: What's happening to R library and/or ADT 14 in Eclipse?

I've just installed the SDK and all the stuff necessary for programming Android in Eclipse for the first time, and I've just find my first problem. After opening a sample project (Snake, for 2.2), there seem to be errors in the code. Well, the R library was not imported. I don't get why it was not already there, but I've imported it. All good? Nope! text = getString(R.string.tie);still has an error. Same with the rest of code (when it uses R). tie is not recognized, it's not shown in that usual blue of Eclipse.

Eclipse says that the problem is ADT 14... final stuff, or switch statements. Ok... I've read that. There's no switch there. That's not the problem. Eclipse suggests me to change .tie to any other thing... like button1. That's not useful, of course. I think the problem is R class, not ADT. Or maybe R class has some final statement so it is not accepted.

I've tried to see if it was that and, in opening the R.class, I get this message: "The source attacement does not contain the source for the file R.class." What now?

Upvotes: 0

Views: 724

Answers (3)

pahan
pahan

Reputation: 2453

try using project-->clean in eclipse. if you imported R library remove it. and try again

Upvotes: 0

Dan Calinescu
Dan Calinescu

Reputation: 71

Make sure you have the required package installed in the AVD Manager. Then, check your Problems view in Eclipse and look at all other errors, other then the R-related ones and make sure everything else is fixed first. If you have an error anywhere in your XML layouts for example, R will not generated.

Upvotes: 0

Malcolm
Malcolm

Reputation: 41510

R is not a library, it is a resources file, which is generated automatically during the build from existing resources. Just make sure that resources are properly placed where they belong. Then build the project and everything will be OK.

Upvotes: 2

Related Questions