Listing 8.4 activity_crime.xml

Greetings,

 My name is Al. I've been working through Criminal Intent for quite awhile now but keep running into a runtime error. At first, I thought maybe the app had too much memory for my phone because Android Studio didn't show any errors. So, I deleted my first attempt at criminal intent and started over to see if I could catch my error. Upon learning more information about stack trace I was able to track the problem down.

I'm confused because the directions say to rename activity_crime.xml to activity_fragment.xml. It also says to change the reference manually if Android Studio didn't do so. I've tried it a few different ways to get setContentView() on singleFragmentActivity to accept the data but still can't quite figure it out. I will post my stack trace, my activity_crime, my activity_fragment, and singleFragment Activity codes below.

This is my stack trace:
at com.bignerdranch.android.criminalintent.SingleFragmentActivity.onCreate(SingleFragmentActivity.java:20)

This is the line stack trace leads to:
setContentView(R.layout.activity_fragment);

This is the SingleFragmentActivity.Java class:
package com.bignerdranch.android.criminalintent;

When I ran the debugger it said the savedInstanceState was null, this is the debuggers output:
@Override
protected void onCreate(Bundle savedInstanceState) //SavedInstanceState: null
{
super.onCreate(savedInstanceState); //SavedInstanceState: null
setContentView(R.layout.activity_fragment);//This is the stack trace Java line 20

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AppCompatActivity;

/**

  • Created by JB on 12/14/2017.
    */
    //8.8 Adding a generic superclass
    public abstract class SingleFragmentActivity extends AppCompatActivity
    {
    protected abstract Fragment createFragment();

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_fragment);//This is the stack trace line???

     //7.15 Getting the FragmentManager
     FragmentManager fm = getSupportFragmentManager();
    
     //7.16 Adding a CrimeFragment
     Fragment fragment = fm.findFragmentById(R.id.fragment_container); //container view ID
     if (fragment == null)
     {
         fragment = createFragment();
         fm.beginTransaction().add(R.id.fragment_container, fragment).commit();
         //fragment_container was created in activity_fragmentent.xml
    
     }//end of if statement
    

    }//end of onCreate(Bundle)

}//end abstract SingleFragmentActivity class

This is the activity_fragment.xml file:

<?xml version="1.0" encoding="utf-8"?>

This is the activity_crime.xml file:

<?xml version="1.0" encoding="utf-8"?>

I will continue to research. Thank you in advance for any advice.

I’ve deleted my program again to restart it but I found a discussion similar to my problem in this forum.

Basically it explains that the appcompat -v7:26.1.0 has to have the matching version recyclerview. I haven’t made it back to the point of where my error occurred to know if it will work but many people within that discussion said it worked for them.