title: NullPointerException on MrNom
body: <p>I was trying to execute Mr Nom(from the book Begining Android Games by Mario Zechner). but it doesn't work. My first atemp was create 2 different projects, one called framework where are com.badlogic.androidgames.framework and com.badlogic.androidgames.framework files and other project called mrnom (com.badlogic.androidgames.mrnom)with the rest of files. the framework project was added mrnom project/java build path/project/add and the result was this:</p>
  
  <p><strong>logcat</strong></p>
  
  <pre><code>       11-07 15:21:55.573: W/dalvikvm(641): Unable to resolve superclass of Lcom/badlogic/androidgames/mrnom/MrNom; (445)
  11-07 15:21:55.573: W/dalvikvm(641): Link of class 'Lcom/badlogic/androidgames/mrnom/MrNom;' failed
  11-07 15:21:55.573: D/AndroidRuntime(641): Shutting down VM
  11-07 15:21:55.573: W/dalvikvm(641): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
  11-07 15:21:55.583: E/AndroidRuntime(641): FATAL EXCEPTION: main
  11-07 15:21:55.583: E/AndroidRuntime(641): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.badlogic.androidgames.mrnom/com.badlogic.androidgames.mrnom.MrNom}: java.lang.ClassNotFoundException: com.badlogic.androidgames.mrnom.MrNom
  11-07 15:21:55.583: E/AndroidRuntime(641):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1983)
  11-07 15:21:55.583: E/AndroidRuntime(641):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
  11-07 15:21:55.583: E/AndroidRuntime(641):    at android.app.ActivityThread.access$600(ActivityThread.java:130)
  11-07 15:21:55.583: E/AndroidRuntime(641):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
  11-07 15:21:55.583: E/AndroidRuntime(641):    at android.os.Handler.dispatchMessage(Handler.java:99)
  11-07 15:21:55.583: E/AndroidRuntime(641):    at android.os.Looper.loop(Looper.java:137)
  11-07 15:21:55.583: E/AndroidRuntime(641):    at android.app.ActivityThread.main(ActivityThread.java:4745)
  11-07 15:21:55.583: E/AndroidRuntime(641):    at java.lang.reflect.Method.invokeNative(Native Method)
  11-07 15:21:55.583: E/AndroidRuntime(641):    at java.lang.reflect.Method.invoke(Method.java:511)
  11-07 15:21:55.583: E/AndroidRuntime(641):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
  11-07 15:21:55.583: E/AndroidRuntime(641):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
  11-07 15:21:55.583: E/AndroidRuntime(641):    at dalvik.system.NativeStart.main(Native Method)
  11-07 15:21:55.583: E/AndroidRuntime(641): Caused by: java.lang.ClassNotFoundException: com.badlogic.androidgames.mrnom.MrNom
  11-07 15:21:55.583: E/AndroidRuntime(641):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
  11-07 15:21:55.583: E/AndroidRuntime(641):    at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
  11-07 15:21:55.583: E/AndroidRuntime(641):    at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
  11-07 15:21:55.583: E/AndroidRuntime(641):    at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
  11-07 15:21:55.583: E/AndroidRuntime(641):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974)
  11-07 15:21:55.583: E/AndroidRuntime(641):    ... 11 more
  11-07 15:24:06.602: E/Trace(662): error opening trace file: No such file or directory (2)
  11-07 15:24:06.902: W/dalvikvm(662): Unable to resolve superclass of Lcom/badlogic/androidgames/mrnom/MrNom; (445)
  11-07 15:24:06.902: W/dalvikvm(662): Link of class 'Lcom/badlogic/androidgames/mrnom/MrNom;' failed
  11-07 15:24:06.902: D/AndroidRuntime(662): Shutting down VM
  11-07 15:24:06.932: W/dalvikvm(662): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
  11-07 15:24:06.952: E/AndroidRuntime(662): FATAL EXCEPTION: main
  11-07 15:24:06.952: E/AndroidRuntime(662): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.badlogic.androidgames.mrnom/com.badlogic.androidgames.mrnom.MrNom}: java.lang.ClassNotFoundException: com.badlogic.androidgames.mrnom.MrNom
  11-07 15:24:06.952: E/AndroidRuntime(662):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1983)
  11-07 15:24:06.952: E/AndroidRuntime(662):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
  11-07 15:24:06.952: E/AndroidRuntime(662):    at android.app.ActivityThread.access$600(ActivityThread.java:130)
  11-07 15:24:06.952: E/AndroidRuntime(662):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
  11-07 15:24:06.952: E/AndroidRuntime(662):    at android.os.Handler.dispatchMessage(Handler.java:99)
  11-07 15:24:06.952: E/AndroidRuntime(662):    at android.os.Looper.loop(Looper.java:137)
  11-07 15:24:06.952: E/AndroidRuntime(662):    at android.app.ActivityThread.main(ActivityThread.java:4745)
  11-07 15:24:06.952: E/AndroidRuntime(662):    at java.lang.reflect.Method.invokeNative(Native Method)
  11-07 15:24:06.952: E/AndroidRuntime(662):    at java.lang.reflect.Method.invoke(Method.java:511)
  11-07 15:24:06.952: E/AndroidRuntime(662):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
  11-07 15:24:06.952: E/AndroidRuntime(662):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
  11-07 15:24:06.952: E/AndroidRuntime(662):    at dalvik.system.NativeStart.main(Native Method)
  11-07 15:24:06.952: E/AndroidRuntime(662): Caused by: java.lang.ClassNotFoundException: com.badlogic.androidgames.mrnom.MrNom
  11-07 15:24:06.952: E/AndroidRuntime(662):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
  11-07 15:24:06.952: E/AndroidRuntime(662):    at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
  11-07 15:24:06.952: E/AndroidRuntime(662):    at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
  11-07 15:24:06.952: E/AndroidRuntime(662):    at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
  11-07 15:24:06.952: E/AndroidRuntime(662):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974)
  11-07 15:24:06.952: E/AndroidRuntime(662):    ... 11 more
  </code></pre>
  
  <p>later I removed the framework from mrnom and added it using a jar file, the result was the same</p>
  
  <p>Now, I copy the com.badlogic.androidgames.framework and com.badlogic.androidgames.framework files into mr project then I have com.badlogic.androidgames.mrnom, com.badlogic.androidgames.framework and com.badlogic.androidgames.framework in the same project but now the error is</p>
  
  <p><strong>logcat</strong></p>
  
  <pre><code>    12-05 15:42:43.510: D/dalvikvm(582): GC_EXTERNAL_ALLOC freed 57K, 53% free 2569K/5379K, external 1925K/2137K, paused 239ms
  12-05 15:42:43.860: D/dalvikvm(582): GC_EXTERNAL_ALLOC freed 3K, 53% free 2569K/5379K, external 2515K/2701K, paused 36ms
  12-05 15:42:44.100: W/dalvikvm(582): threadid=11: thread exiting with uncaught exception (group=0x40015560)
  12-05 15:42:44.100: E/AndroidRuntime(582): FATAL EXCEPTION: Thread-12
  12-05 15:42:44.100: E/AndroidRuntime(582): java.lang.NullPointerException
  12-05 15:42:44.100: E/AndroidRuntime(582):    at com.badlogic.androidgames.mrnom.Settings.load(Settings.java:18)
  12-05 15:42:44.100: E/AndroidRuntime(582):    at com.badlogic.androidgames.mrnom.LoadingScreen.update(LoadingScreen.java:41)
  12-05 15:42:44.100: E/AndroidRuntime(582):    at com.badlogic.androidgames.framework.impl.AndroidFastRenderView.run(AndroidFastRenderView.java:36)
  12-05 15:42:44.100: E/AndroidRuntime(582):    at java.lang.Thread.run(Thread.java:1019)
  </code></pre>
  
  <p><strong>Settings</strong></p>
  
  <pre><code>    package com.badlogic.androidgames.mrnom;
  
  import java.io.BufferedReader;
  import java.io.BufferedWriter;
  import java.io.IOException;
  import java.io.InputStreamReader;
  import java.io.OutputStreamWriter;
  
  import com.balogic.androidgames.framework.FileIO;
  
  public class Settings {
     public static boolean soundEnable=true;
     public static int[] highscores=new int[]{100,80,50,30,10};
  
     public static void load(FileIO files){
        BufferedReader in=null;
        try{
           in=new BufferedReader(new InputStreamReader(files.readFile(".mrnom")));// line 18 error here
           soundEnable=Boolean.parseBoolean(in.readLine());
           for(int i=0; i&lt;5;i++){
              highscores[i]=Integer.parseInt(in.readLine());
           }
        }catch(IOException e){
           // :( vale,trabajamos con valores predeterminados
        }catch(NumberFormatException e){
           // :/ vale, estos valores nos han salvado el día
        }finally{
           try{
              if(in!=null)
                 in.close();
           }catch(IOException e){
              //nada
           }
        }
     }
     public static void save(FileIO files){
        BufferedWriter out=null;
        try{
           out=new BufferedWriter(new OutputStreamWriter(files.writeFile(".mrnom")));
           out.write(Boolean.toString(soundEnable));
           for(int i=0; i&lt;5; i++){
              out.write(Integer.toString(highscores[i]));
           }
        }catch(IOException e){
           //nada
        }finally{
           try{
              if(out!=null)
                 out.close();
           }catch(IOException e){
              //nada
           }
        }
     }
     public static void addScore(int score){
        for(int i=0;i&lt;5;i++){
           if(highscores[i]&lt;score){
              for(int j=4;j&gt;i;j--)
                 highscores[j]=highscores[j-1];
              highscores[i]=score;
              break;
           }
        }
     }
  }
  </code></pre>
  
  <p><strong>Loadingsceen</strong></p>
  
  <pre><code>    package com.badlogic.androidgames.mrnom;
  
  import com.badlogic.androidgames.framework.Game;
  import com.badlogic.androidgames.framework.Graphics;
  import com.badlogic.androidgames.framework.Graphics.PixmapFormat;
  import com.badlogic.androidgames.framework.Screen;
  
  
  public class LoadingScreen extends Screen{
     public LoadingScreen(Game game){
        super(game);
     }
     @Override
     public void update(float deltaTime){
        Graphics g=game.getGraphics();
        Assets.background = g.newPixmap("background.png", PixmapFormat.RGB565);
  
        Assets.logo = g.newPixmap("logo.png", PixmapFormat.ARGB4444);
          Assets.mainMenu = g.newPixmap("mainmenu.png", PixmapFormat.ARGB4444);
          Assets.buttons = g.newPixmap("buttons.png", PixmapFormat.ARGB4444);
          Assets.help1 = g.newPixmap("help1.png", PixmapFormat.ARGB4444);
          Assets.help2 = g.newPixmap("help2.png", PixmapFormat.ARGB4444);
          Assets.help3 = g.newPixmap("help3.png", PixmapFormat.ARGB4444);
          Assets.numbers = g.newPixmap("numbers.png", PixmapFormat.ARGB4444);
          Assets.ready = g.newPixmap("ready.png", PixmapFormat.ARGB4444);
          Assets.pause = g.newPixmap("pausemenu.png", PixmapFormat.ARGB4444);
          Assets.gameOver = g.newPixmap("gameover.png", PixmapFormat.ARGB4444);
          Assets.headUp = g.newPixmap("headup.png", PixmapFormat.ARGB4444);
          Assets.headLeft = g.newPixmap("headleft.png", PixmapFormat.ARGB4444);
          Assets.headDown = g.newPixmap("headdown.png", PixmapFormat.ARGB4444);
          Assets.headRight = g.newPixmap("headright.png", PixmapFormat.ARGB4444);
          Assets.tail = g.newPixmap("tail.png", PixmapFormat.ARGB4444);
          Assets.stain1 = g.newPixmap("stain.png", PixmapFormat.ARGB4444);
          Assets.stain2 = g.newPixmap("stain2.png", PixmapFormat.ARGB4444);
          Assets.stain3 = g.newPixmap("stain3.png", PixmapFormat.ARGB4444);
  
          Assets.click = game.getAudio().newSound("click.ogg");
          Assets.eat = game.getAudio().newSound("eat.ogg");
          Assets.bitten = game.getAudio().newSound("bitten.ogg");
  
          Settings.load(game.getFileIO()); //line 41 error here
          game.setScreen(new MainMenuScreen(game));
     }
     @Override
     public void present(float deltaTime) {
        // TODO Auto-generated method stub
  
     }
     @Override
     public void pause() {
        // TODO Auto-generated method stub
  
     }
     @Override
     public void resume() {
        // TODO Auto-generated method stub
  
     }
     @Override
     public void dispose() {
        // TODO Auto-generated method stub
  
     }
  
  }
  </code></pre>
  
  <p><strong>AndroidFastRenderView</strong></p>
  
  <pre><code>    package com.badlogic.androidgames.framework.impl;
  
  import android.graphics.Bitmap;
  import android.graphics.Canvas;
  import android.graphics.Rect;
  import android.view.SurfaceHolder;
  import android.view.SurfaceView;
  
  public class AndroidFastRenderView extends SurfaceView implements Runnable{
     AndroidGame game;
     Bitmap framebuffer;
     Thread renderThread=null;
     SurfaceHolder holder;
     volatile boolean running=false;
  
     public AndroidFastRenderView(AndroidGame game,Bitmap framebuffer){      
        super(game);
        this.game=game;
        this.framebuffer=framebuffer;
        this.holder=getHolder();
     }
     public void resume(){
        running=true;
        renderThread=new Thread(this);
        renderThread.start();
     }
     public void run(){
        Rect dstRect=new Rect();
        long startTime=System.nanoTime();
        while(running){
           if(!holder.getSurface().isValid())
              continue;
           float deltaTime=(System.nanoTime()-startTime)/1000000000.0f;
           startTime=System.nanoTime();
  
  game.getCurrentScreen().update(deltaTime);//line 36 error here
           game.getCurrentScreen().present(deltaTime);
  
           Canvas canvas=holder.lockCanvas();
           canvas.getClipBounds(dstRect);
           canvas.drawBitmap(framebuffer, null, dstRect,null);
           holder.unlockCanvasAndPost(canvas);
        }
     }
     public void pause(){
        running=false;
        while(true){
           try{
              renderThread.join();
              break;
           }catch(InterruptedException e){
              //vuelve a intentarlo
           }
        }
     }
  }
  </code></pre>
  
  <p>Eclipse doesn't showme any mistake on code but on the emulator just say "Sorry! the application mrnom (process com.badlogic.androidgames.mrnom) has stopped unexpectedly. Please try again"</p>
  
  <p>Can you help me with this? No idea what's happening :( Thank you so much.</p>