Why does my code throw a ClassNotFoundException?
<p>I'm trying to simply place an image, <code>dotpowder.png</code>, where you touch the screen. Simple enough, right? Apparently not, as the image is to be a class, with attributes so I can treat it as a dynamic object instead of an ImageView. Here is the code for the <code>DotCanvas.java</code>:</p>

<pre><code>package com.dhg.dots;

import android.content.Context;
import android.view.View;
import android.view.MotionEvent;
import android.graphics.Canvas;
import android.graphics.Point;

public class DotCanvas extends View {
    private Context mContext;
    public DotCanvas(Context context) {
        super(context);
        setFocusable(true);
        mContext = context;
    }
    private DotBase dot;

    @Override protected void onDraw(Canvas canvas) {
        for (int i = 0; i &lt; DotHandler.dotList.size(); i++) {
            dot = DotHandler.dotList.get(i);
            dot.setY(dot.getY() + 1);

            canvas.drawBitmap(dot.getBitmap(), dot.getX(), dot.getY(), null);
        }
    }

    public boolean onTouchEvent(MotionEvent event) {
        Point dotPoint = new Point();
        dotPoint.x = (int)event.getX();
        dotPoint.y = (int)event.getY();
        new DotPowder(mContext, dotPoint.x, dotPoint.y);
        invalidate();
        return true;
    }
}
</code></pre>

<p>And this is the <strong>updated</strong> <code>DotBase.java</code>:</p>

<pre><code>package com.dhg.dots;

import android.graphics.Bitmap;
import android.content.Context;
import android.graphics.BitmapFactory;

public class DotBase {
    private Context mContext;
    private Bitmap dotBitmap;

    public DotBase(Context context, float x, float y) {
        DotHandler.addDotToArray(this);
        mContext = context;
        Bitmap bitmap = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.dotpowder);
        dotBitmap = bitmap;
        xCoord = x;
        yCoord = y;
    }

    private float xCoord;
    private float yCoord;

    public void setX(float x) {
        xCoord = x;
    }

    public void setY(float y) {
        yCoord = y;
    }

    public float getX() {
        return xCoord;
    }

    public float getY() {
        return yCoord;
    }

    public void setGraphic(int id) {
        dotBitmap = BitmapFactory.decodeResource(mContext.getResources(), id);
    }

    public Bitmap getBitmap() {
        return dotBitmap;
    }
}
</code></pre>

<p>And finally, here is <code>DotPowder.java</code>:</p>

<pre><code>package com.dhg.dots;

import android.content.Context;

public class DotPowder extends DotBase {
    public DotPowder(Context context, float x, float y) {
        super(context, x, y);

        setGraphic(R.drawable.dotpowder);
    }
}
</code></pre>

<p>The <code>ClassNotFoundException</code> occurs when the new <code>DotBase</code> is instantiated, but I have no idea why.</p>

<p>P.S. Here is DotHandler.java, the main Activity:</p>

<pre><code>package com.dhg.dots;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.os.Bundle;

public class DotHandler extends Activity {
    /** Called when the activity is first created. */
    public static List&lt;DotBase&gt; dotList = new ArrayList&lt;DotBase&gt;() {
    private static final long serialVersionUID = -946727550332680940L;
    };
    @Override public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(new DotCanvas(this));
    }

    public static void addDotToArray(DotBase dot) {
        if (dotList.size() == 0) {
            dotList.add(0, dot);
        }
        else {
            dotList.add(dotList.size() + 1, dot);
        }
    }
}
</code></pre>

<p>And here is the stack trace:</p>

<pre><code>java.lang.NullPointerException
    at com.dhg.dots.DotBase.&lt;init&gt;(DotBase.java:17)
    at com.dhg.dots.DotPowder.&lt;init&gt;(DotPowder.java:7)
    at com.dhg.dots.DotCanvas.onTouchEvent(DotCanvas.java:32)
    at android.view.View.dispatchTouchEvent(View.java:3778)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:885)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:885)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:885)
    at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1716)
    at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1124)
    at android.app.Activity.dispatchTouchEvent(Activity.java:2125)
    at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1700)
    at android.view.ViewRoot.handleMessage(ViewRoot.java:1802)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:143)
    at android.app.ActivityThread.main(ActivityThread.java:5061)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:521)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
    at dalvik.system.NativeStart.main(Native Method)
java.lang.NullPointerException
    at com.dhg.dots.DotBase.&lt;init&gt;(DotBase.java:17)
    at com.dhg.dots.DotPowder.&lt;init&gt;(DotPowder.java:7)
    at com.dhg.dots.DotCanvas.onTouchEvent(DotCanvas.java:32)
    at android.view.View.dispatchTouchEvent(View.java:3778)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:958)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:958)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:958)
    at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1716)
    at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1124)
    at android.app.Activity.dispatchTouchEvent(Activity.java:2125)
    at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1700)
    at android.view.ViewRoot.handleMessage(ViewRoot.java:1802)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:143)
    at android.app.ActivityThread.main(ActivityThread.java:5061)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:521)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
    at dalvik.system.NativeStart.main(Native Method)
java.lang.NullPointerException
    at com.dhg.dots.DotBase.&lt;init&gt;(DotBase.java:17)
    at com.dhg.dots.DotPowder.&lt;init&gt;(DotPowder.java:7)
    at com.dhg.dots.DotCanvas.onTouchEvent(DotCanvas.java:32)
    at android.view.View.dispatchTouchEvent(View.java:3778)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:958)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:958)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:958)
    at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1716)
    at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1124)
    at android.app.Activity.dispatchTouchEvent(Activity.java:2125)
    at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1700)
    at android.view.ViewRoot.handleMessage(ViewRoot.java:1802)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:143)
    at android.app.ActivityThread.main(ActivityThread.java:5061)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:521)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
    at dalvik.system.NativeStart.main(Native Method)
</code></pre>

<p>Also, as you can tell from the stack trace, it has started throwing NullPointerExceptions as well.</p>
