title: FATAL EXCEPTION: main error - Android development
body: <p>I am currently making an android app and am trying to resolve this issue. Whenever I compile my code and lode it onto the emulator, it initially loads up with these errors:</p>
  
  <pre><code>05-22 00:12:54.753: W/dalvikvm(1631): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
  05-22 00:12:54.783: E/AndroidRuntime(1631): FATAL EXCEPTION: main
  05-22 00:12:54.783: E/AndroidRuntime(1631): java.lang.RuntimeException: Unable to instantiate application android.app.Application: java.lang.NullPointerException
  05-22 00:12:54.783: E/AndroidRuntime(1631):     at android.app.LoadedApk.makeApplication(LoadedApk.java:482)
  05-22 00:12:54.783: E/AndroidRuntime(1631):     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3938)
  05-22 00:12:54.783: E/AndroidRuntime(1631):     at android.app.ActivityThread.access$1300(ActivityThread.java:123)
  05-22 00:12:54.783: E/AndroidRuntime(1631):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1185)
  05-22 00:12:54.783: E/AndroidRuntime(1631):     at android.os.Handler.dispatchMessage(Handler.java:99)
  05-22 00:12:54.783: E/AndroidRuntime(1631):     at android.os.Looper.loop(Looper.java:137)
  05-22 00:12:54.783: E/AndroidRuntime(1631):     at android.app.ActivityThread.main(ActivityThread.java:4424)
  05-22 00:12:54.783: E/AndroidRuntime(1631):     at java.lang.reflect.Method.invokeNative(Native Method)
  05-22 00:12:54.783: E/AndroidRuntime(1631):     at java.lang.reflect.Method.invoke(Method.java:511)
  05-22 00:12:54.783: E/AndroidRuntime(1631):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
  05-22 00:12:54.783: E/AndroidRuntime(1631):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
  05-22 00:12:54.783: E/AndroidRuntime(1631):     at dalvik.system.NativeStart.main(Native Method)
  05-22 00:12:54.783: E/AndroidRuntime(1631): Caused by: java.lang.NullPointerException
  05-22 00:12:54.783: E/AndroidRuntime(1631):     at android.app.LoadedApk.initializeJavaContextClassLoader(LoadedApk.java:362)
  05-22 00:12:54.783: E/AndroidRuntime(1631):     at android.app.LoadedApk.getClassLoader(LoadedApk.java:305)
  05-22 00:12:54.783: E/AndroidRuntime(1631):     at android.app.LoadedApk.makeApplication(LoadedApk.java:474)
  05-22 00:12:54.783: E/AndroidRuntime(1631):     ... 11 more
  </code></pre>
  
  <p>Then it kicks me out of the app with a force close but it boots back up soon after automatically and runs just fine. If I close the app and kill it, it doesn't force close or anything. Just when it initially boots up on the emulator. I was wondering what would be the reasoning for this. Here are the messages that pop up after it loads up the second time:</p>
  
  <pre><code>05-22 00:13:07.113: D/dalvikvm(1664): GC_FOR_ALLOC freed 38K, 3% free 9110K/9347K, paused 61ms
  05-22 00:13:07.165: I/dalvikvm-heap(1664): Grow heap (frag case) to 12.525MB for 3732496-byte allocation
  05-22 00:13:07.263: D/dalvikvm(1664): GC_CONCURRENT freed 1K, 2% free 12754K/12999K, paused 5ms+5ms
  05-22 00:13:07.543: D/dalvikvm(1664): GC_FOR_ALLOC freed &lt;1K, 2% free 12755K/12999K, paused 37ms
  05-22 00:13:07.573: I/dalvikvm-heap(1664): Grow heap (frag case) to 14.502MB for 2073616-byte allocation
  05-22 00:13:07.753: D/dalvikvm(1664): GC_CONCURRENT freed &lt;1K, 2% free 14780K/15047K, paused 5ms+5ms
  05-22 00:13:08.033: D/gralloc_goldfish(1664): Emulator without GPU emulation detected.
  </code></pre>
  
  <p>I will supply you with any and all coding you guys need but unfortunately I do not know where this error would be at? I have many files inside of my program so I would rather not post all of them if at all possible.</p>
  
  <p>Sorry that this question hasn't given much information, I just don't know what information to give to you (if that makes sense?) Please respond and tell me what information you would need and thank you for any and all of your help</p>
  
  <h2>EDIT</h2>
  
  <p>here is my splash.java</p>
  
  <pre><code>package com.food;
  
  import com.food.odu.R;
  import android.app.Activity;
  import android.content.Intent;
  import android.os.Bundle;
  
  //creating a splash effect so the company logo appears for a few seconds before the program
  public class Splash extends Activity{
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          // TODO Auto-generated method stub
          super.onCreate(savedInstanceState);
          setContentView(R.layout.splash);  //defined the reference id 'splash' in the splash.xml file
  
          Thread timer = new Thread(){    //creates a new timer for our splash effect
              public void run(){   //runs the splash program
                  try{
                       sleep(5000);    //attempts to run the splash picture for 5000 milliseconds (5 seconds)
                     } catch(InterruptedException e){
                        e.printStackTrace();    //if that doesn't work, this line is debugging information
                        }finally{
                          Intent openStartingPoint = new Intent("com.rhodes.jacob.COM.FOOD.ODUACTIVITY"); //creating an intent which is basically a reference to the Android Manifest
                          startActivity(openStartingPoint);                                               //file saying that when this intent is called, to go to the address at that name in the Android Manifest file
                        }
                    }
  
          };
  
          timer.start();
  
      }
  
      @Override
      protected void onPause() {
          // TODO Auto-generated method stub
          super.onPause();
          finish();
      }
  
  
  
  }
  </code></pre>
  
  <hr>
  
  <p>and here is my oduActivity.java (my main, i suppose)</p>
  
  <pre><code>package com.food;
  
  
  import com.food.odu.R;
  //import com.food.odu.R;
  import android.app.Activity;
  import android.content.Intent;
  import android.os.Bundle;
  import android.view.Menu;
  import android.view.MenuInflater;
  import android.view.MenuItem;
  import android.view.View;
  import android.widget.Button;
  import android.widget.TextView;
  
  
  
  public class oduActivity extends Activity {
      /** Called when the activity is first created. */
  
      Button Cafe1201, Legends, Rogers, Faculty;
      TextView display;
  
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
  
          super.onCreate(savedInstanceState);        
          setContentView(R.layout.main);
  
          Button Cafe1201 = (Button)findViewById(R.id.cafe1201);
          Button Legends = (Button)findViewById(R.id.legends);
          Button Rogers = (Button)findViewById(R.id.rogers);
          Button Faculty = (Button)findViewById(R.id.fac_n_staff);
  
    //    Button Legal = (Button)findViewById(R.id.legal);
    //    Button Other = (Button)findViewById(R.id.other);
    //    Button About = (Button)findViewById(R.id.aboutUs);
          //Button Mainpage = (Button)findViewById(R.id.main_page);
  
          //Changes page to the cafe1201 page
          Cafe1201.setOnClickListener(new View.OnClickListener() {
              public void onClick(View v) {
                  Intent whichCafe = new Intent(oduActivity.this,cafe1201.class);
                  startActivity(whichCafe);
  
              }
          });
  
  
           //changes page to the legends page
            Legends.setOnClickListener(new View.OnClickListener() {
                  public void onClick(View v) {
                      Intent whichCafe = new Intent(oduActivity.this,legends.class);
                      startActivity(whichCafe);
  
                  }
              }); 
  
  
            //changes page to the rogers page
            Rogers.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    Intent whichCafe = new Intent(oduActivity.this,rogers.class);
                    startActivity(whichCafe);
  
                }
            }); 
  
  
            //changes page to the faculty page
            Faculty.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    Intent whichCafe = new Intent(oduActivity.this,faculty.class);
                    startActivity(whichCafe);
  
                }
            }); 
  
  
      }
  
      //Options menu
      @Override
      public boolean onCreateOptionsMenu(android.view.Menu menu) {
          // TODO Auto-generated method stub
          super.onCreateOptionsMenu(menu);
          MenuInflater blowUp = getMenuInflater();
          blowUp.inflate(R.menu.menu, menu);
          return true;
  
      }
  
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          // TODO Auto-generated method stub
          switch(item.getItemId()){
  
          case R.id.main_page:
  
              Intent whichOption = new Intent(oduActivity.this,oduActivity.class);
              startActivity(whichOption);
              break;
          case R.id.other:
  
              whichOption = new Intent(oduActivity.this,menu.class);
              startActivity(whichOption);
              break;
          case R.id.aboutUs:
  
              whichOption = new Intent(oduActivity.this,aboutUs.class);
              startActivity(whichOption);
              break;
          case R.id.legal:
  
              whichOption = new Intent(oduActivity.this,legal.class);
              startActivity(whichOption);
              break;
  
          }
          return false;
      }
  
  
  
  
  
  
       //   display = (TextView) findViewById(R.id.tvDisplay);
    //  }
   }
  </code></pre>