• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps ADT and Eclipse integration problems?

neckar

Lurker
Mar 8, 2009
1
0
Hello all,

I've installed the android SDK, Eclipse and the ADT plugin (got all the latest versions from the official websites: eclipse 3.4.2 from which I installed the ADT plugin and SDK 1.1_r1 from google).

I've set the SDK in eclipse and also added it to the PATH environment variable (I'm running Win XP SP2) and have entered the necessary Run configurations settings in eclipse.

Yet trying to open each of the sample projects and create a Hello Android project of my own consistently gets the following error from eclipse: R cannot be resolved.

I still don't know much about the framework but have read that the R.java is suppose to be generated automatically. Eclipse suggests adding an import to android.R, but the tutorial I'm reading seems to have no such import and even if I add the import the problem persist as the 'main' class simply isn't there.

I've changed the relevant code so to omit the use of the R class from this:

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

to this:

TextView tv = new TextView(this);
tv.setText("Hello, Android");
setContentView(tv);

While this did make the aforementioned error go away I still couldn't run the project since eclipse doesn't seem to work well with the ADT plugin (that's my guess at least) and the doesn't build the project.

When I Run it I get the following output on the console:

[2009-03-08 09:19:09 - Hello Android] ----------------------
[2009-03-08 09:19:09 - Hello Android] Android Launch!
[2009-03-08 09:19:09 - Hello Android] adb is running normally.
[2009-03-08 09:19:09 - Hello Android] Could not find Hello Android.apk!

The emulatore doesn't start of course. It seems to me like there's a problem with the ADT and Eclipse so that the projects aren't created properly (that R.java file is suppose to be created automatically according to what I've read).

any clues as to what's gone wrong here and how can I fix it?
 
The R.java file is supposed to be generated automatically - sometimes there's issues getting it to regenerate itself. It's usually due to a problem with the AndroidManifest.xml file in the project, or an error stopping it from running within the code.

Using Control-B, you can rebuild if it's not happening automatically. I'd suggest checking the manifest and any build errors, then building and see if it helps.

Edit: also, don't import the android.R, as it's something completely separate.
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones