I'm working on this app for fun, it's suppose to simulate a double pendulum, but when I run the app it works for a few frames then crashes and its not clear when it crashes. This is the error code
09-04 14:07:23.047 10097-10097/com.example.doubletrouble E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.doubletrouble, PID: 10097
java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference
    at com.jjoe64.graphview.GridLabelRenderer.calcLabelVerticalSize(GridLabelRenderer.java:1001)
    at com.jjoe64.graphview.GridLabelRenderer.draw(GridLabelRenderer.java:1099)
    at com.jjoe64.graphview.GraphView.drawGraphElements(GraphView.java:307)
    at com.jjoe64.graphview.GraphView.onDraw(GraphView.java:336)
    at android.view.View.draw(View.java:16238)
    at android.view.View.updateDisplayListIfDirty(View.java:15235)
    at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3637)
    at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3617)
    at android.view.View.updateDisplayListIfDirty(View.java:15195)
    at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3637)
    at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3617)
    at android.view.View.updateDisplayListIfDirty(View.java:15195)
    at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3637)
    at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3617)
    at android.view.View.updateDisplayListIfDirty(View.java:15195)
    at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3637)
    at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3617)
    at android.view.View.updateDisplayListIfDirty(View.java:15195)
    at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3637)
    at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3617)
    at android.view.View.updateDisplayListIfDirty(View.java:15195)
    at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:3637)
    at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3617)
    at android.view.View.updateDisplayListIfDirty(View.java:15195)
    at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:281)
    at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:287)
    at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:322)
    at android.view.ViewRootImpl.draw(ViewRootImpl.java:2681)
    at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2495)
    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2124)
    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1140)
    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6239)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
    at android.view.Choreographer.doCallbacks(Choreographer.java:670)
    at android.view.Choreographer.doFrame(Choreographer.java:606)
    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5551)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:731)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:621)
Just as a heads up, I'm new to programming in the android-studio IDE. I've gone line by line through the debugger and it seems less likely to crash if I got through the debugger slowly. Maybe a memory allocation thing?
public class MainActivity extends AppCompatActivity {
    private double theta1=45*Math.PI/180;
    private double theta2=45*Math.PI/180;
    private double mass1=1;
    private double mass2=1;
    private double length1=1;
    private double length2=1;
    private double[] nextThetas= new double[2];
    private boolean on = true;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        GraphView graph= findViewById(R.id.graph);
        // set manual X bounds
        graph.getViewport().setXAxisBoundsManual(true);
        graph.getViewport().setMinX(0);
        graph.getViewport().setMaxX(10);
        // set manual Y bounds
        graph.getViewport().setYAxisBoundsManual(true);
        graph.getViewport().setMinY(0);
        graph.getViewport().setMaxY(10);
        evolveSys();
    }
    //This function is my attempt at getting the code to update the graph after a short delay
    @Override
    protected void onResume()
    {
        super.onResume();
        new Thread(new Runnable()
        {
            @Override
            public void run()
            {
                while(on)
                {
                    evolveSys();
                    try {
                        Thread.sleep(300);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    } finally {
                    }
                }
            }
        }).start();
    }
    //This function clears the graph and redraws the pendulum with the new angles
    private void evolveSys()
    {
        GraphView graph= findViewById(R.id.graph);
        graph.removeAllSeries();
        makePendulum Pendulum = new makePendulum();
        Pendulum.pendulum(graph,theta1,theta2,mass1,mass2,length1,length2);
        evolvePendulum pendulum = new evolvePendulum();
        nextThetas=pendulum.evolve(theta1,theta2,mass1,mass2,length1,length2);
        theta1=nextThetas[0];
        theta2=nextThetas[1];
    }
}
All the other classes I use in the code work fine. Let me know your thoughts and if there is a better way to execute what I'm trying to do.
 
    