aspose file tools*
The moose likes Android and the fly likes Error: Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Android
Bookmark "Error: "R cannot be resolved"" Watch "Error: "R cannot be resolved"" New topic
Author

Error: "R cannot be resolved"

Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

Hello everybody,
I am trying to run my first program in android but I got error.

I havae following code in my .java file



and following in my main.xml file



But when I tried to run the program I got 3 error as "R can not be resolved" at shown above.



I had to find out solution for this but my problem is not solved. Some forum says make another program and run it. I tried it for 3 times but every time I got same error as "R can not be resolved". Please help me.

Thank you


Life is easy because we write the source code.....
Ksh Aggarwal
Greenhorn

Joined: Sep 16, 2009
Posts: 28
This error is because eclipse cannot find 'R.java' file.

You have to import the 'R.java' file manually since eclipse has not done so itself.
Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

Hello ksh I had import the file but still i get 2 errors.

Thanks for reply
Ksh Aggarwal
Greenhorn

Joined: Sep 16, 2009
Posts: 28
Pramod P Deore wrote:Hello ksh I had import the file but still i get 2 errors.


Could you please specify the import you made and the errors?
Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

I had imported as


but it still gives 2 errors as "R.id can not be resolved"

Thanks
Ksh Aggarwal
Greenhorn

Joined: Sep 16, 2009
Posts: 28
It seems to be some eclipse issue. Try restarting the IDE. There is not much more i can help you with this problem.
Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

Hello Ksh,
I don't know how but erros are now solved but now on emulator following error is generated as
"The application NewApp(process com.micro) has stopped unexpectedly. Please try again".
and "Force clode" button is displayed.

Thanks
Ksh Aggarwal
Greenhorn

Joined: Sep 16, 2009
Posts: 28
Check the logcat of the emulator. your application has encountered some error. you can find the exception stack trace in the logcat
Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

I am not getting any clue from Error.Log file.


[Thumbnail for error.jpeg]

Ksh Aggarwal
Greenhorn

Joined: Sep 16, 2009
Posts: 28
You have to veiw the logcat in DDMS. its a view option in eclipse. select the emulator from the left and see the logcat window for the logs created by emulator
Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

sorry for silly questions, but will you please tell me how to view logcat in DDMS. I can't find view option in eclipse.

Thanks
Ksh Aggarwal
Greenhorn

Joined: Sep 16, 2009
Posts: 28
go to Window>Open perspective>others. Select DDMS
There you have devices window on left and LogCat window at bottom. Select the emulator from device window nd you can then veiw the logs in LogCat window. This is where all your logs (error trace and println commands) will be shown.
Use it for some time. U'll get used to it
Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

Thanks Ksh,

for your help, now I am able to open Logcat but I didin't get any clue.
Ksh Aggarwal
Greenhorn

Joined: Sep 16, 2009
Posts: 28
Pramod P Deore wrote:
for your help, now I am able to open Logcat but I didin't get any clue.


Now run the application again and see the logcat as the application progresses. an error in application will create a error trace in red color in logcat.
Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

ok wait for 5 min
Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

I got following error messages , I am sending only red colour (error) messages..


Ksh Aggarwal
Greenhorn

Joined: Sep 16, 2009
Posts: 28
Error in your application is reported in line 54

add as the first statement in your onCreate method to remove this error
Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

Thanks Ksh,
It works
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error: "R cannot be resolved"