• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Error: "R cannot be resolved"

 
Ranch Hand
Posts: 633
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 633
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 633
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 633
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 633
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 633
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 633
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 633
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok wait for 5 min
 
Pramod P Deore
Ranch Hand
Posts: 633
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 633
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ksh,
It works
 
Every plan is a little cooler if you have a blimp. And a tiny ad.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic