1

I am developing a whack-a-mole game for android in eclipse. My app works on android 2.2 but not on newer versions. What happens is that the splashscreen loads fine and my main activity starts fine too, but to start the game you need to tap the first screen of the main activity. When you do that the emulator shows: "Unfortunately my app stopped"

I came across a similar question here, but I couldn't find out what I had to do if this was the problem in my code.

Logcat:

07-04 12:08:49.029: E/InputEventReceiver(2099): Exception dispatching input event.
07-04 12:08:49.049: E/MessageQueue-JNI(2099): Exception in MessageQueue callback: handleReceiveCallback
07-04 12:08:49.329: E/MessageQueue-JNI(2099): java.lang.NullPointerException
07-04 12:08:49.329: E/MessageQueue-JNI(2099):   at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:589)
07-04 12:08:49.329: E/MessageQueue-JNI(2099):   at com.jellyproductions.holymoly.HolyMolyView$WhackAMoleThread.doTouchEvent(HolyMolyView.java:460)
07-04 12:08:49.329: E/MessageQueue-JNI(2099):   at com.jellyproductions.holymoly.HolyMolyView.onTouchEvent(HolyMolyView.java:1691)
07-04 12:08:49.329: E/MessageQueue-JNI(2099):   at android.view.View.dispatchTouchEvent(View.java:7706)
07-04 12:08:49.329: E/MessageQueue-JNI(2099):   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
07-04 12:08:49.329: E/MessageQueue-JNI(2099):   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
07-04 12:08:49.329: E/MessageQueue-JNI(2099):   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
07-04 12:08:49.329: E/MessageQueue-JNI(2099):   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
07-04 12:08:49.329: E/MessageQueue-JNI(2099):   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
07-04 12:08:49.329: E/MessageQueue-JNI(2099):   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
07-04 12:08:49.329: E/MessageQueue-JNI(2099):   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
07-04 12:08:49.329: E/MessageQueue-JNI(2099):   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
07-04 12:08:49.329: E/MessageQueue-JNI(2099):   at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2068)
07-04 12:08:49.329: E/MessageQueue-JNI(2099):   at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1515)
07-04 12:08:49.329: E/MessageQueue-JNI(2099):   at android.app.Activity.dispatchTouchEvent(Activity.java:2458)
07-04 12:08:49.329: E/MessageQueue-JNI(2099):   at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2016)
07-04 12:08:49.329: E/MessageQueue-JNI(2099):   at android.view.View.dispatchPointerEvent(View.java:7886)
07-04 12:08:49.329: E/MessageQueue-JNI(2099):   at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:3954)
07-04 12:08:49.329: E/MessageQueue-JNI(2099):   at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3833)
07-04 12:08:49.329: E/MessageQueue-JNI(2099):   at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3399)
07-04 12:08:49.329: E/MessageQueue-JNI(2099):   at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3449)
07-04 12:08:49.329: E/MessageQueue-JNI(2099):   at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3418)
07-04 12:08:49.329: E/MessageQueue-JNI(2099):   at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3525)
07-04 12:08:49.329: E/MessageQueue-JNI(2099):   at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3426)
07-04 12:08:49.329: E/MessageQueue-JNI(2099):   at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3582)
07-04 12:08:49.329: E/MessageQueue-JNI(2099):   at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3399)
07-04 12:08:49.329: E/MessageQueue-JNI(2099):   at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3449)
07-04 12:08:49.329: E/MessageQueue-JNI(2099):   at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3418)
07-04 12:08:49.329: E/MessageQueue-JNI(2099):   at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3426)
07-04 12:08:49.329: E/MessageQueue-JNI(2099):   at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3399)
07-04 12:08:49.329: E/MessageQueue-JNI(2099):   at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5602)
07-04 12:08:49.329: E/MessageQueue-JNI(2099):   at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5582)
07-04 12:08:49.329: E/MessageQueue-JNI(2099):   at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5553)
07-04 12:08:49.329: E/MessageQueue-JNI(2099):   at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:5682)
07-04 12:08:49.329: E/MessageQueue-JNI(2099):   at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
07-04 12:08:49.329: E/MessageQueue-JNI(2099):   at android.os.MessageQueue.nativePollOnce(Native Method)
07-04 12:08:49.329: E/MessageQueue-JNI(2099):   at android.os.MessageQueue.next(MessageQueue.java:138)
07-04 12:08:49.329: E/MessageQueue-JNI(2099):   at android.os.Looper.loop(Looper.java:123)
07-04 12:08:49.329: E/MessageQueue-JNI(2099):   at android.app.ActivityThread.main(ActivityThread.java:5017)
07-04 12:08:49.329: E/MessageQueue-JNI(2099):   at java.lang.reflect.Method.invokeNative(Native Method)
07-04 12:08:49.329: E/MessageQueue-JNI(2099):   at java.lang.reflect.Method.invoke(Method.java:515)
07-04 12:08:49.329: E/MessageQueue-JNI(2099):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
07-04 12:08:49.329: E/MessageQueue-JNI(2099):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
07-04 12:08:49.329: E/MessageQueue-JNI(2099):   at dalvik.system.NativeStart.main(Native Method)
07-04 12:08:49.339: D/AndroidRuntime(2099): Shutting down VM
07-04 12:08:49.339: W/dalvikvm(2099): threadid=1: thread exiting with uncaught exception (group=0xb3a4cba8)
07-04 12:08:49.569: E/AndroidRuntime(2099): FATAL EXCEPTION: main
07-04 12:08:49.569: E/AndroidRuntime(2099): Process: com.jellyproductions.holymoly, PID: 2099
07-04 12:08:49.569: E/AndroidRuntime(2099): java.lang.NullPointerException
07-04 12:08:49.569: E/AndroidRuntime(2099):     at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:589)
07-04 12:08:49.569: E/AndroidRuntime(2099):     at com.jellyproductions.holymoly.HolyMolyView$WhackAMoleThread.doTouchEvent(HolyMolyView.java:460)
07-04 12:08:49.569: E/AndroidRuntime(2099):     at com.jellyproductions.holymoly.HolyMolyView.onTouchEvent(HolyMolyView.java:1691)
07-04 12:08:49.569: E/AndroidRuntime(2099):     at android.view.View.dispatchTouchEvent(View.java:7706)
07-04 12:08:49.569: E/AndroidRuntime(2099):     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
07-04 12:08:49.569: E/AndroidRuntime(2099):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
07-04 12:08:49.569: E/AndroidRuntime(2099):     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
07-04 12:08:49.569: E/AndroidRuntime(2099):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
07-04 12:08:49.569: E/AndroidRuntime(2099):     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
07-04 12:08:49.569: E/AndroidRuntime(2099):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
07-04 12:08:49.569: E/AndroidRuntime(2099):     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2216)
07-04 12:08:49.569: E/AndroidRuntime(2099):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1959)
07-04 12:08:49.569: E/AndroidRuntime(2099):     at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2068)
07-04 12:08:49.569: E/AndroidRuntime(2099):     at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1515)
07-04 12:08:49.569: E/AndroidRuntime(2099):     at android.app.Activity.dispatchTouchEvent(Activity.java:2458)
07-04 12:08:49.569: E/AndroidRuntime(2099):     at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2016)
07-04 12:08:49.569: E/AndroidRuntime(2099):     at android.view.View.dispatchPointerEvent(View.java:7886)
07-04 12:08:49.569: E/AndroidRuntime(2099):     at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:3954)
07-04 12:08:49.569: E/AndroidRuntime(2099):     at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3833)
07-04 12:08:49.569: E/AndroidRuntime(2099):     at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3399)
07-04 12:08:49.569: E/AndroidRuntime(2099):     at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3449)
07-04 12:08:49.569: E/AndroidRuntime(2099):     at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3418)
07-04 12:08:49.569: E/AndroidRuntime(2099):     at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3525)
07-04 12:08:49.569: E/AndroidRuntime(2099):     at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3426)
07-04 12:08:49.569: E/AndroidRuntime(2099):     at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3582)
07-04 12:08:49.569: E/AndroidRuntime(2099):     at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3399)
07-04 12:08:49.569: E/AndroidRuntime(2099):     at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3449)
07-04 12:08:49.569: E/AndroidRuntime(2099):     at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3418)
07-04 12:08:49.569: E/AndroidRuntime(2099):     at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3426)
07-04 12:08:49.569: E/AndroidRuntime(2099):     at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3399)
07-04 12:08:49.569: E/AndroidRuntime(2099):     at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5602)
07-04 12:08:49.569: E/AndroidRuntime(2099):     at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5582)
07-04 12:08:49.569: E/AndroidRuntime(2099):     at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5553)
07-04 12:08:49.569: E/AndroidRuntime(2099):     at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:5682)
07-04 12:08:49.569: E/AndroidRuntime(2099):     at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
07-04 12:08:49.569: E/AndroidRuntime(2099):     at android.os.MessageQueue.nativePollOnce(Native Method)
07-04 12:08:49.569: E/AndroidRuntime(2099):     at android.os.MessageQueue.next(MessageQueue.java:138)
07-04 12:08:49.569: E/AndroidRuntime(2099):     at android.os.Looper.loop(Looper.java:123)
07-04 12:08:49.569: E/AndroidRuntime(2099):     at android.app.ActivityThread.main(ActivityThread.java:5017)
07-04 12:08:49.569: E/AndroidRuntime(2099):     at java.lang.reflect.Method.invokeNative(Native Method)
07-04 12:08:49.569: E/AndroidRuntime(2099):     at java.lang.reflect.Method.invoke(Method.java:515)
07-04 12:08:49.569: E/AndroidRuntime(2099):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
07-04 12:08:49.569: E/AndroidRuntime(2099):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
07-04 12:08:49.569: E/AndroidRuntime(2099):     at dalvik.system.NativeStart.main(Native Method)

DoTouchEvent Method:

boolean doTouchEvent(MotionEvent event) {
        synchronized (mySurfaceHolder) {
            int eventaction = event.getAction();

            int X = (int) event.getX();
            int Y = (int) event.getY();

            switch (eventaction) {

            case MotionEvent.ACTION_DOWN:
                if (!gameOver) {
                    fingerX = X;
                    fingerY = Y;
                    if (!onTitle && detectMoleHit()) {
                        whacking = true;
                        molesWhacked++;
                        if (molesWhacked < highscore) {
                            highscore = highscore;
                        } else if (molesWhacked == highscore) {
                            molesWhacked = highscore;
                        } else if (molesWhacked > highscore) {
                            highscore++;
                        }
                    }
                }
                break;

            case MotionEvent.ACTION_MOVE:
                break;

            case MotionEvent.ACTION_UP:
                if (onTitle || gameOver || gameOverRed || gameOverBlue
                        || gameOverGreen || gameOverPink || gameOverYellow) {

                    BitmapFactory.Options options = new BitmapFactory.Options();
                    options.inJustDecodeBounds = true;

                    backgroundImg = BitmapFactory.decodeResource(
                            myContext.getResources(),
                            R.drawable.background, options);
                    backgroundImg = Bitmap.createScaledBitmap( **//Line 460**
                            backgroundImg, screenW, screenH, true);
                    maskup = BitmapFactory.decodeResource(
                            myContext.getResources(), R.drawable.maskup,
                            options);
                    maskmiddle = BitmapFactory.decodeResource(
                            myContext.getResources(),
                            R.drawable.maskmiddle, options);
                    maskdown = BitmapFactory.decodeResource(
                            myContext.getResources(), R.drawable.maskdown,
                            options);
                    molered = BitmapFactory.decodeResource(
                            myContext.getResources(), R.drawable.molered,
                            options);
                    moleblue = BitmapFactory.decodeResource(
                            myContext.getResources(), R.drawable.moleblue,
                            options);
                    molegreen = BitmapFactory.decodeResource(
                            myContext.getResources(), R.drawable.molegreen,
                            options);
                    molepink = BitmapFactory.decodeResource(
                            myContext.getResources(), R.drawable.molepink,
                            options);
                    moleyellow = BitmapFactory.decodeResource(
                            myContext.getResources(),
                            R.drawable.moleyellow, options);
                    whack = BitmapFactory.decodeResource(
                            myContext.getResources(), R.drawable.whack,
                            options);
                    gameoverred = BitmapFactory.decodeResource(
                            myContext.getResources(),
                            R.drawable.gameoverred, options);
                    gameoverblue = BitmapFactory.decodeResource(
                            myContext.getResources(),
                            R.drawable.gameoverblue, options);
                    gameovergreen = BitmapFactory.decodeResource(
                            myContext.getResources(),
                            R.drawable.gameovergreen, options);
                    gameoverpink = BitmapFactory.decodeResource(
                            myContext.getResources(),
                            R.drawable.gameoverpink, options);
                    gameoveryellow = BitmapFactory.decodeResource(
                            myContext.getResources(),
                            R.drawable.gameoveryellow, options);
                    scaleW = (float) screenW / (float) backgroundOrigW;
                    scaleH = (float) screenH / (float) backgroundOrigH;
                    maskup = Bitmap.createScaledBitmap(maskup,
                            (int) (maskup.getWidth() * scaleW),
                            (int) (maskup.getHeight() * scaleH), true);
                    maskmiddle = Bitmap.createScaledBitmap(maskmiddle,
                            (int) (maskmiddle.getWidth() * scaleW),
                            (int) (maskmiddle.getHeight() * scaleH), true);
                    maskdown = Bitmap.createScaledBitmap(maskdown,
                            (int) (maskdown.getWidth() * scaleW),
                            (int) (maskdown.getHeight() * scaleH), true);
                    molered = Bitmap.createScaledBitmap(molered,
                            (int) (molered.getWidth() * scaleW),
                            (int) (molered.getHeight() * scaleH), true);
                    moleblue = Bitmap.createScaledBitmap(moleblue,
                            (int) (moleblue.getWidth() * scaleW),
                            (int) (moleblue.getHeight() * scaleH), true);
                    molegreen = Bitmap.createScaledBitmap(molegreen,
                            (int) (molegreen.getWidth() * scaleW),
                            (int) (molegreen.getHeight() * scaleH), true);
                    molepink = Bitmap.createScaledBitmap(molepink,
                            (int) (molepink.getWidth() * scaleW),
                            (int) (molepink.getHeight() * scaleH), true);
                    moleyellow = Bitmap.createScaledBitmap(moleyellow,
                            (int) (moleyellow.getWidth() * scaleW),
                            (int) (moleyellow.getHeight() * scaleH), true);
                    whack = Bitmap.createScaledBitmap(whack,
                            (int) (whack.getWidth() * scaleW),
                            (int) (whack.getHeight() * scaleH), true);
                    gameoverred = Bitmap.createScaledBitmap(gameoverred,
                            screenW, screenH, true);
                    gameoverblue = Bitmap.createScaledBitmap(gameoverblue,
                            screenW, screenH, true);
                    gameovergreen = Bitmap.createScaledBitmap(
                            gameovergreen, screenW, screenH, true);
                    gameoverpink = Bitmap.createScaledBitmap(gameoverpink,
                            screenW, screenH, true);
                    gameoveryellow = Bitmap.createScaledBitmap(
                            gameoveryellow, screenW, screenH, true);
                    onTitle = false;

                    pickMole();
                }
                whacking = false;
                if (gameOver || gameOverRed || gameOverBlue
                        || gameOverGreen || gameOverPink || gameOverYellow) {
                    if (molesWhacked > highscore) {
                        molesWhacked = highscore;
                    } else if (molesWhacked == highscore) {
                        molesWhacked = highscore;
                    } else if (molesWhacked < highscore) {
                        highscore = highscore;
                    }

                    molesWhacked = 0;
                    molesMissed = 0;
                    activeMoleR = 0;
                    activeMoleB = 0;
                    activeMoleG = 0;
                    activeMoleP = 0;
                    activeMoleY = 0;

                    pickMoleColor();

                    gameOver = false;
                    gameOverRed = false;
                    gameOverBlue = false;
                    gameOverGreen = false;
                    gameOverPink = false;
                    gameOverYellow = false;

                    pickMole();
                }
                break;
            } **//Line 589**
        }
        return true;
    }

OnTouchEvent Method:

@Override
public boolean onTouchEvent(MotionEvent event) {
    return thread.doTouchEvent(event); **//Line 1691**
}

Main Actvity XML:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

    <com.jellyproductions.holymoly.HolyMolyView
        android:id="@+id/mole"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"/>

    <com.google.ads.AdView android:id="@+id/adView"
                     android:layout_width="350dp"
                     android:layout_height="50dp"
                     android:layout_alignParentBottom="true"
                     ads:adUnitId=".............."
                     ads:adSize="BANNER"
                     ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID"
                     ads:loadAdOnCreate="true"/>

I have noticed that some people said that I have set a variable to null, which it shouldn't be, but I think I haven't done that. I really am struggling with what I have to do now and I have been searching google and SO for other questions/posts related to this subject, but I still haven't found a solution...

Community
  • 1
  • 1
user3707951
  • 29
  • 2
  • 8
  • `backgroundImg` is `null`. – m0skit0 Jul 05 '14 at 16:20
  • The only place where backgroundImg is null is here: *canvas.drawBitmap(backgroundImg, 0, 0, **null**);* @m0skit0 – user3707951 Jul 06 '14 at 10:10
  • Could that be the problem? @m0skit0 – user3707951 Jul 06 '14 at 10:11
  • I came across [this question](http://stackoverflow.com/questions/17554452/canvas-null-pointer-exception) and noticed that the cause may be that my *Canvas c = null*, but what could I do to fix the problem then? @m0skit0 – user3707951 Jul 06 '14 at 10:17
  • No, it could be null after `backgroundImg = BitmapFactory.decodeResource(myContext.getResources(), R.drawable.background, options);`. Log its value and we'll see. – m0skit0 Jul 06 '14 at 20:26
  • There is no null after that line, so I'm assuming you ment removing the null here `canvas.drawBitmap(backgroundImg, 0, 0, null);`, but when I did that I got the error: `The method drawBitmap(Bitmap, Mtrix, Paint) in the type Canvas is not applicable for the arguments(Bitmap, int, int)` @m0skit0 – user3707951 Jul 07 '14 at 20:06
  • *"There is no null after that line"* I mean variable `backgroundImg` has `null` value, not that there's a `null` value written. – m0skit0 Jul 10 '14 at 14:11
  • How could `backgroundImg` have a `null` value when it is never stated? @m0skit0 – user3707951 Jul 13 '14 at 14:59
  • What does "never stated" even mean? You're getting a NullPointerException, isn't that enough statement? Again: log the value of `backgroundImg` and you'll see. – m0skit0 Jul 15 '14 at 20:18
  • How would you log a value? I am not really an advanced programmer as you can probably notice... @m0skit0 – user3707951 Jul 17 '14 at 10:16
  • `Log.d("Some tag", "backgroundImg value is " + backgroundImg)` – m0skit0 Jul 17 '14 at 11:25
  • `07-17 09:17:29.562: D/Some tag(4032): backgroundImg value is android.graphics.Bitmap@b470cf00` – user3707951 Jul 17 '14 at 13:17
  • @m0skit0 So what do I do now? – user3707951 Jul 17 '14 at 13:17
  • Where did you put the log? – m0skit0 Jul 17 '14 at 13:50
  • After backgroundImg decodeResource and createScaledBitmap in my doTouchEvent method @m0skit0 – user3707951 Jul 17 '14 at 13:58
  • You put 2 logs but you only showed me one output... – m0skit0 Jul 17 '14 at 14:13
  • No I put one log after both of those I mentioned above, like this: backgroundImg = BitmapFactory .decodeResource(myContext.getResources(), R.drawable.background); backgroundImg = Bitmap.createScaledBitmap( backgroundImg, screenW, screenH, true); Log.d("Some tag", "backgroundImg value is " + backgroundImg); @m0skit0 – user3707951 Jul 17 '14 at 14:24
  • I meant you should put it before the line that triggers the NPE. Also if log has shown this way, you didn't get the NPE... – m0skit0 Jul 18 '14 at 11:19

0 Answers0