Fatal Exception. App crashes on start : <p>please I  am new to android development.I am working on the flag quiz app on ditel's android 6 for programmers.  Although I followed the source code meticulously, I don't seem to be able to run the app successfully, as it crashes almost immediately after coming up. This is the exception I  am getting. I would appreciate  any help that will solve this problem. </p>

<pre><code>     FATAL EXCEPTION: main
                                                                       Process: com.example.israel.flagquiz, PID: 4644
                                                                       java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.israel.flagquiz/com.example.israel.flagquiz.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.example.israel.flagquiz.MainActivityFragment.updateGuessRows(android.content.SharedPreferences)' on a null object reference
                                                                           at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2521)
                                                                           at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2601)
                                                                           at android.app.ActivityThread.access$800(ActivityThread.java:178)
                                                                           at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1470)
                                                                           at android.os.Handler.dispatchMessage(Handler.java:111)
                                                                           at android.os.Looper.loop(Looper.java:194)
                                                                           at android.app.ActivityThread.main(ActivityThread.java:5637)
                                                                           at java.lang.reflect.Method.invoke(Native Method)
                                                                           at java.lang.reflect.Method.invoke(Method.java:372)
                                                                           at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
                                                                           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
                                                                        Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.example.israel.flagquiz.MainActivityFragment.updateGuessRows(android.content.SharedPreferences)' on a null object reference
                                                                           at com.example.israel.flagquiz.MainActivity.onStart(MainActivity.java:62)
                                                                           at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1244)
                                                                           at android.app.Activity.performStart(Activity.java:6140)
                                                                           at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2478)
                                                                           at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2601) 
                                                                           at android.app.ActivityThread.access$800(ActivityThread.java:178) 
                                                                           at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1470) 
                                                                           at android.os.Handler.dispatchMessage(Handler.java:111) 
                                                                           at android.os.Looper.loop(Looper.java:194) 
                                                                           at android.app.ActivityThread.main(ActivityThread.java:5637) 
                                                                           at java.lang.reflect.Method.invoke(Native Method) 
                                                                           at java.lang.reflect.Method.invoke(Method.java:372) 
                                                                           at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960) 
                                                                           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755) 
</code></pre>

<p>pertinent  code  in MainActivity</p>

<pre><code>@Override
protected void onStart(){
    super.onStart();

        if (preferencesChanged){
                MainActivityFragment quizFragment = (MainActivityFragment)
                        getSupportFragmentManager().findFragmentById(R.id.quizFragment);
            quizFragment.updateGuessRows(
                    PreferenceManager.getDefaultSharedPreferences(this));
            quizFragment.updateRegions(
                    PreferenceManager.getDefaultSharedPreferences(this));
            quizFragment.resetQuiz();
            preferencesChanged = false;
        }
</code></pre>

<p>pertinent  code in Main Activity Fragment</p>

<pre><code>              public void updateGuessRows(SharedPreferences sharedPreferences){
       String choices = new String();
     choices = sharedPreferences.getString(MainActivity.CHOICES, null);
    guessRows = Integer.parseInt(choices) / 2;

    for (LinearLayout layout: guessLinearLayouts)
        layout.setVisibility(View.GONE);

    for (int row = 0; row &lt; guessRows; row++)
        guessLinearLayouts[row].setVisibility(View.VISIBLE);
}
</code></pre>
