Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error: "R cannot be resolved"

 
Pramod P Deore
Ranch Hand
Posts: 632
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ksh Aggarwal
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 632
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello ksh I had import the file but still i get 2 errors.

Thanks for reply
 
Ksh Aggarwal
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 632
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had imported as


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

Thanks
 
Ksh Aggarwal
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 632
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 632
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not getting any clue from Error.Log file.
error.jpeg
[Thumbnail for error.jpeg]
 
Ksh Aggarwal
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 632
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 632
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ksh,

for your help, now I am able to open Logcat but I didin't get any clue.
 
Ksh Aggarwal
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 632
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok wait for 5 min
 
Pramod P Deore
Ranch Hand
Posts: 632
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got following error messages , I am sending only red colour (error) messages..


 
Ksh Aggarwal
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 632
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ksh,
It works
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic