Cannot resolve symbol 'recyclerView'

I’m on Listing 20.7 Configuring RecyclerView (BeatBoxFragment.java)

The compiler won’t recognize the recyclerView symbol field for binding.
A copy and paste is shown below, see the line of code that reads …
binding.recyclerView.setLayoutManager( new GridLayoutManager(getActivity(),3));

What am I doing wrong??

package com.bignerdranch.android.beatbox;

import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.bignerdranch.android.beatbox.databinding.FragmentBeatBoxBinding;

public class BeatBoxFragment extends Fragment {
public static BeatBoxFragment newInstance() {
return new BeatBoxFragment();
}

@Override
public View onCreateView(LayoutInflater inflater,
                         ViewGroup container,
                         Bundle savedInstanceState) {
    FragmentBeatBoxBinding binding = DataBindingUtil
            .inflate( inflater, R.layout.fragment_beat_box, container, false);

    binding.recyclerView.setLayoutManager( new GridLayoutManager(getActivity(),3));

    return binding.getRoot();
}

}

I’m getting the same issue. Anyone found the fix for this?

Just restarted Android Studio and the “Cannot resolve symbol” error went away for me.

I added compile ‘com.android.support:recyclerview-v7:26.+’ under dependencies in my build.gradle file and it worked.

1 Like

I had the same issue. I changed my keywords from “implement” to “compile” on my gradle build file to make it work.

In my case, just add the below line in to build.gradle file:
implementation ‘com.android.support:recyclerview-v7:28.0.0’