title: java.lang.NullPointerException: Attempt to invoke virtual method 'android.graphics.RectF
body: <p>I'm kinda new to this all android game development and need a little help..my game is crashing and i cant find to solve the problem..Thank you in advance.</p>
  
  <pre><code>public class BrickBreaker extends AppCompatActivity {
  
      BreakerView brickView;
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          brickView = new BreakerView(this);
          setContentView(brickView);
      }
  
  
      private class BreakerView extends SurfaceView implements Runnable {
  
          Canvas canvas;
          Paint paint;
  
          Thread gameThread = null;
  
          SurfaceHolder ourHolder;
  
          volatile boolean playing;
  
          boolean paused = true;
  
          long fps;
  
          private long timeThisFrame;
  
          int screenX;
          int screenY;
  
          Paddle paddle;
  
          @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
          public BreakerView(Context context) {
              super(context);
              this.ourHolder = getHolder();
              this.paint = new Paint();
  
              //res
              Display display = getWindowManager().getDefaultDisplay();
              Point size = new Point();
              display.getSize(size);
  
              screenX = size.x;
              screenY = size.y;
          }
  
  
          @Override
          public void run() {
              while (playing) {
                  long startFrameTime = System.currentTimeMillis();
  
                  if (!paused) {
                      update();
                  }
  
                  draw();
  
                  timeThisFrame = System.currentTimeMillis() - startFrameTime;
                  if (timeThisFrame &gt;= 1) {
                      fps = 1000 / timeThisFrame;
                  }
              }
          }
  
          public void update() {
              paddle.update(fps);
          }
  
          public void draw() {
              if (ourHolder.getSurface().isValid()) {
                  canvas = ourHolder.lockCanvas();
  
                  canvas.drawColor(Color.argb(255, 26, 128, 182));
  
                  paint.setColor(Color.argb(255, 255, 255, 255));
  
                  canvas.drawRect(paddle.getRect(), paint);
  
  
                  ourHolder.unlockCanvasAndPost(canvas);
              }
          }
  
          public void pause() {
              playing = false;
              try {
                  gameThread.join();
              } catch (InterruptedException e) {
                  Log.e("Error:", "joining thread");
              }
  
          }
  
          public void resume() {
              playing = true;
              gameThread = new Thread(this);
              gameThread.start();
          }
  
          @Override
          public boolean onTouchEvent(MotionEvent motionEvent) {
  
              switch (motionEvent.getAction() &amp; MotionEvent.ACTION_MASK) {
  
                  case MotionEvent.ACTION_DOWN:
  
                      paused = false;
  
                      if(motionEvent.getX() &gt; screenX / 2){
                          paddle.setMovementState(paddle.RIGHT);
                      }
                      else{
                          paddle.setMovementState(paddle.LEFT);
                      }
  
                      break;
  
                  case MotionEvent.ACTION_UP:
  
                      paddle.setMovementState(paddle.STOPPED);
  
                      break;
              }
              return true;
          }
  
  
      //end of breakView
      }
  
      @Override
      protected void onResume() {
          super.onResume();
  
          brickView.resume();
      }
  
      @Override
      protected void onPause() {
          super.onPause();
  
          brickView.pause();
      }
  </code></pre>
  
  <p>and here is the log</p>
  
  <pre><code>05-06 15:19:43.119 27243-27287/? E/AndroidRuntime: FATAL EXCEPTION: Thread-30652
                                                 Process: com.example.david.brickbreakergame, PID: 27243
                                                 java.lang.NullPointerException: Attempt to invoke virtual method 'android.graphics.RectF com.example.david.brickbreakergame.Paddle.getRect()' on a null object reference
                                                     at com.example.david.brickbreakergame.BrickBreaker$BreakerView.draw(BrickBreaker.java:99)
                                                     at com.example.david.brickbreakergame.BrickBreaker$BreakerView.run(BrickBreaker.java:78)
                                                     at java.lang.Thread.run(Thread.java:818)
  </code></pre>