Q:

android application toturial 74

i'm following "thenewboston"'s toturial on youtube, i'm at the 74th toturial and i get a FC right after i touch the screen in the "GFXSurface" app. i try debugging and it stops on the line "canvas.drawBitmap(test, (x - (test.getWidth() / 2)),(y - (test.getHeight() / 2)), null);"
any ideas?
here is the link for the toturial:
http://www.youtube.com/watch?v=PmOtvJqDfqY
and here is my code:
public class GFXSurface extends Activity implements OnTouchListener {

    MyBringBackSurface ourSurfaceView;
    float x, y, sX, sY, fX, fY;
    Bitmap test, plus;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        ourSurfaceView = new MyBringBackSurface(this);
        ourSurfaceView.setOnTouchListener(this);
        Bitmap test = BitmapFactory.decodeResource(getResources(),
                R.drawable.green_ball);
        Bitmap plus = BitmapFactory.decodeResource(getResources(),
                R.drawable.button_plus);
        x=0;
        y=0;
        sX=0;
        sY=0;
        fX=0;
        fY=0;
        setContentView(ourSurfaceView);
    }

    @Override
    protected void onPause() {
        // TODO Auto-generated method stub
        super.onPause();
        ourSurfaceView.pause();
    }

    @Override
    protected void onResume() {
        // TODO Auto-generated method stub
        super.onResume();
        ourSurfaceView.resume();
    }

    @Override
    public boolean onTouch(View arg0, MotionEvent event) {
        // TODO Auto-generated method stub
        x = event.getX();
        y = event.getY();

        switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
            sX = event.getX();
            sY = event.getY();
            break;
        case MotionEvent.ACTION_UP:
            fX = event.getX();
            fY = event.getY();
            break;
        }
        return true;
    }

    public class MyBringBackSurface extends SurfaceView implements Runnable {

        SurfaceHolder ourHolder;
        Thread ourThread = null;
        Boolean isRunning = false;

        public MyBringBackSurface(Context context) {
            super(context);
            // TODO Auto-generated constructor stub
            ourHolder = getHolder();

        }

        public void pause() {
            isRunning = false;
            while (true) {
                try {
                    ourThread.join();
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                break;
            }
            ourThread = null;
        }

        public void resume() {
            isRunning = true;
            ourThread = new Thread(this);
            ourThread.start();
        }

        @Override
        public void run() {
            // TODO Auto-generated method stub
            while (isRunning) {
                if (!ourHolder.getSurface().isValid())
                    continue;

                Canvas canvas = ourHolder.lockCanvas();
                canvas.drawRGB(23, 233, 254);

                if (x != 0 && y != 0) {

                    canvas.drawBitmap(test, (x - (test.getWidth() / 2)),
                            (y - (test.getHeight() / 2)), null);
                }
                if (sX != 0 && sY != 0) {

                    canvas.drawBitmap(plus, (sX - (plus.getWidth() / 2)),
                            (sY - (plus.getHeight() / 2)), null);
                }
                if (fX != 0 && fY != 0) {

                    canvas.drawBitmap(plus, (fX - (plus.getWidth() / 2)),
                            (fY - (plus.getHeight() / 2)), null);
                }

                ourHolder.unlockCanvasAndPost(canvas);
            }
        }

    }
}

}

A:

Bitmap test = BitmapFactory.decodeResource(getResources(),
                R.drawable.green_ball);

Should be:
test = BitmapFactory.decodeResource(getResources(),
                R.drawable.green_ball);

The test variable in the class isn't ever getting set, and is null when you try to use it.
(The same goes for your plus variable)

