setContextView(R.layout.main) fails

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

setContextView(R.layout.main) fails

Postby meluzi » Thu Oct 15, 2009 9:58 pm

Hi,

I was trying to implement the Image Capture code published here : http://www.androidph.com/2008/11/camera-capture.html

I've copied the code as is and have made changes to all files, given permissions in the Manifest etc as mentioned in the guide. However on launching the emulator, the error msg pops up:
The Application Image,Capture has stopped unexpectedly. Please try again

I tried to debug the code by stepping in but cannot get past the line :
setContentView(R.layout.main);

The R.java generated contains main :

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. /* AUTO-GENERATED FILE.  DO NOT MODIFY.
  2.  
  3.  *
  4.  
  5.  * This class was automatically generated by the
  6.  
  7.  * aapt tool from the resource data it found.  It
  8.  
  9.  * should not be modified by hand.
  10.  
  11.  */
  12.  
  13.  
  14.  
  15. package new.img;
  16.  
  17.  
  18.  
  19. public final class R {
  20.  
  21.     public static final class attr {
  22.  
  23.     }
  24.  
  25.     public static final class drawable {
  26.  
  27.         public static final int icon=0x7f020000;
  28.  
  29.     }
  30.  
  31.     public static final class id {
  32.  
  33.         public static final int surface=0x7f050000;
  34.  
  35.     }
  36.  
  37.     public static final class layout {
  38.  
  39.         public static final int main=0x7f030000;
  40.  
  41.     }
  42.  
  43.     public static final class string {
  44.  
  45.         public static final int app_name=0x7f040001;
  46.  
  47.         public static final int hello=0x7f040000;
  48.  
  49.     }
  50.  
  51. }
  52.  
  53.  
Parsed in 0.000 seconds, using GeSHi 1.0.8.4


Can anyone tell me why this happens? I have just started coding on Java and on Android. I have no idea how the DDMS works and cant get around it either. So any advice would be welcome!
meluzi
Freshman
Freshman
 
Posts: 3
Joined: Thu Oct 15, 2009 9:44 pm

Top

Postby wiederke » Fri Oct 16, 2009 12:32 pm

Hi,

you should check the log in LogCat to get the exception, which leads to the foce close dialog.


Bye,

Torsten
wiederke
Experienced Developer
Experienced Developer
 
Posts: 72
Joined: Mon Mar 02, 2009 6:46 pm
Location: Germany

Postby meluzi » Fri Oct 16, 2009 9:16 pm

Torsten,

Got it to work! Thanks for your tip. I used the adb logcat to print the log. The exception was throw due to error inflating class linearlayout and surfaceview in the main.xml. I should've been careful with the case sensitive nature of android. The classes were renamed to LinearLayout and SurfaceView. The program worked!

Thanks and Regards

Mel
meluzi
Freshman
Freshman
 
Posts: 3
Joined: Thu Oct 15, 2009 9:44 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 2 guests