wood burning stoves 2.0*
The moose likes Android and the fly likes Android Tutorial:  Hello World Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "Android Tutorial:  Hello World" Watch "Android Tutorial:  Hello World" New topic
Author

Android Tutorial: Hello World

Preston Thornton
Ranch Hand

Joined: Jun 24, 2008
Posts: 80
Good afternoon, everyone:

Because mobile application are going so viral everywhere, I figured I better learn something quick. So, my journey starts with going to the Android Developers site http://developer.android.com/index.html and downloading the Android SDK.

Reading through the download information, I see the use of Eclipse the associated plug-in, great! I follow the instructions and go to build the Hello world example. I am now getting the following error:

2010-11-16 13:40:23 - HelloAndroid] ERROR: Unable to open class file D:\Galileo\workspace\HelloAndroid\gen\com\example\helloandroid\R.java: No such file or directory


Using Windows Explorer I get:
D:\Galileo\workspace\HelloAndroid\gen\com\example\helloandroid
where I find the file.

I am using Eclipse 3.5.2. Please Advise.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5811
    
    7

This same issue has bugged me about the Eclipse Android plugin. The is generated, but if it doesn't already exist then the build complains. Thge way I get around it is right-click the "gen" folder and create a new class, giving the appropriate package name ("com.example.helloandroid" in your case) and as the class name. Once the class is created, you should be able to build without errors. (Note that you do not have to, and should not, edit the file.)

Sorry for the formatting, but the forum prevents me from using that letter by itself.


JBoss In Action
Preston Thornton
Ranch Hand

Joined: Jun 24, 2008
Posts: 80
You know what, I found a silly work around to this issue. Go up to File -> Restart and then run the build and run the project. It works. Crazy.


Louis Preston Thornton III
A Flex 4 Wantabe
and Android Hopeful
James Elsey
Ranch Hand

Joined: Dec 21, 2007
Posts: 228

Hi Preston,

I've had similar such behaviour in Eclipse. Sometimes eclipse may complain that your project "has errors" and can't compile, yet the source code can be ok.

Best solution I've found, is to "clean" the project. I can't remember where that option is (not in front of an IDE) but somewhere along the top you can go Projects > Clean, I believe

Try that, it might help

Cheers


Kind Regards, James. OCPJP 1.6 || My SCJP / OCJCP Study Notes
Interested in : SCJP, Google App Engine, Stripes, Android;|| My Bite-Size SCJP Study Blog
Chan Vysnow
Greenhorn

Joined: Dec 22, 2009
Posts: 6
Hello, man!

Every time I create a project, this problem happens to me. I think it's nomal. For Eclipse read R.java before the IDE had generated it, it would happen.

Hope to help.

Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5811
    
    7

[I found a silly work around to this issue. Go up to File -> Restart and then run the build and run the project. It works.

I just tried this and it didn't work for me. Here are the step I took:
1) Create a new Android project
2) File | Restart
3) Right-click project and select Build.
Still got the error:



If course, my suggested workaround fixed this.
Lars Vogel
Ranch Hand

Joined: Oct 10, 2007
Posts: 55
In most cases cleaning the project should fix the issue, please see Fixing Issues with the Android SDK for details.


Tutorials about Java, Eclipse and Webprogramming http://www.vogella.de
Patrick Blais
Greenhorn

Joined: Dec 11, 2010
Posts: 1
Hi all,
I've just downloaded Eclipse and installed the Android SDK.

When I try to run the Hello World, I get the following error message

[2010-12-11 13:06:38 - Tutoriel] /Tutoriel/gen already exists but is not a source folder. Convert to a source folder or rename it.
[2010-12-11 13:08:57 - Tutoriel] /Tutoriel/gen already exists but is not a source folder. Convert to a source folder or rename it.
[2010-12-11 13:09:06 - Tutoriel] /Tutoriel/gen already exists but is not a source folder. Convert to a source folder or rename it.

I don't know what to do with this?

I've tried a couple of things but it seems the gen folder is always in the way when trying to run the app.


What am I not understanding here?
Lars Vogel
Ranch Hand

Joined: Oct 10, 2007
Posts: 55
Did you try the solultions from the link I posted?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Android Tutorial: Hello World
 
Similar Threads
Exception in thread "main"
[java] Java Result: 1 error
Could not find HelloAndroid.apk!
Servlet compile problem
android in eclipse