title: How to debug two RecyclerViews that suddenly stopped working?
body: <p>I was working on an Android project that features two fragments on the main activity with one RecyclerView in each of them. It was looking good and functioning as intended, then somewhere along the way something broke and now neither is populating with anything. I'm not sure how to even begin to debug this, as everything looks correct to me. I will just focus on one of the RecyclerViews for the code below. The other one is imported from another project, so it has even less reason to break as I didn't code it! If you need any more information let me know as I am learning as I go here.</p>
  <p>I have tried cleaning the project, rebuilding, restarting Android Studio in case it was a weird cache issue. I have combed over the code but nothing jumps out at me and Android Studio is not raising any errors. The project builds and loads but the Recycler Views are devoid of content.</p>
  <p>build.gradle</p>
  <pre><code>dependencies {
  
  implementation 'androidx.legacy:legacy-support-v4:1.0.0'
  coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
  
  implementation 'androidx.fragment:fragment-ktx:1.4.1'
  implementation 'androidx.core:core-ktx:1.7.0'
  implementation 'androidx.appcompat:appcompat:1.4.1'
  implementation 'com.google.android.material:material:1.5.0'
  implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
  implementation 'androidx.recyclerview:recyclerview:1.2.1'
  implementation project(':crunchycalendar')
  testImplementation 'junit:junit:4.13.2'
  implementation &quot;androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1&quot;
  debugImplementation 'androidx.fragment:fragment-testing:1.4.1'}
  </code></pre>
  <p>CardsFragment.kt</p>
  <pre><code>class CardsFragment : Fragment(R.layout.fragment_cards) {
  
  var sampleDidits : Array&lt;Didit&gt; = arrayOf(
      Didit(&quot;Walk 15 minutes around the block with your dog&quot;, &quot;Grab the earbuds and get outside&quot;, R.drawable.footsteps),
      Didit(&quot;Meditate 20 minutes&quot;, &quot;This flavor text is too long man chill out&quot;, R.drawable.meditation),
      Didit(&quot;Take your meds&quot;, &quot;Withdrawal ain't fun&quot;, R.drawable.pill_bottle)
  )
  
  override fun onCreateView(
      inflater: LayoutInflater, container: ViewGroup?,
      savedInstanceState: Bundle?
  ): View? {
      // Inflate the layout for this fragment
      val binding = FragmentCardsBinding.inflate(layoutInflater, container, false)
  
      // Add the following lines to create RecyclerView
      val recyclerView = binding.cardsRecyclerView
      recyclerView.setHasFixedSize(true);
  
      val snapHelper: SnapHelper = LinearSnapHelper()
      snapHelper.attachToRecyclerView(recyclerView)
  
      val layoutManager = LinearLayoutManager(this.context)
      layoutManager.orientation = LinearLayoutManager.HORIZONTAL
      recyclerView.layoutManager = layoutManager;
  
      recyclerView.adapter = CardViewAdapter(sampleDidits);
  
      return binding.root
  }
  </code></pre>
  <p>}</p>
  <p>fragment_cards.xml</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;layout xmlns:tools=&quot;http://schemas.android.com/tools&quot;
  xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
  xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;&gt;
  
  
  &lt;androidx.constraintlayout.widget.ConstraintLayout
      android:id=&quot;@+id/cf_constraint&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;&gt;
  
      &lt;androidx.recyclerview.widget.RecyclerView
          android:id=&quot;@+id/cardsRecyclerView&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;match_parent&quot;
          android:scrollbars=&quot;horizontal&quot;
          app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
          app:layout_constraintEnd_toEndOf=&quot;parent&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot;
          app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt;
  
  &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  &lt;/layout&gt;
  </code></pre>
  <p>CardViewAdapter.kt</p>
  <pre><code>class CardViewAdapter(private val didit_tasks: Array&lt;Didit&gt;) :
  RecyclerView.Adapter&lt;CardViewAdapter.ViewHolder&gt;() {
  override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
      val cv = LayoutInflater.from(parent.context)
          .inflate(R.layout.didit_card, parent, false) as CardView
      return ViewHolder(cv)
  }
  
  override fun onBindViewHolder(holder: ViewHolder, position: Int) {
      // This is where data is added to the card view
      val cardView = holder.cardView
      val mainText = cardView.findViewById&lt;View&gt;(R.id.maintext) as TextView
      val streakText = cardView.findViewById&lt;View&gt;(R.id.streak_text) as TextView
      val flavorText = cardView.findViewById&lt;View&gt;(R.id.flavorText) as TextView
      val diditIcon = cardView.findViewById&lt;View&gt;(R.id.didit_icon) as ImageView
      val drawable = ContextCompat.getDrawable(cardView.context, didit_tasks[position].icon)
      val streakString = didit_tasks[position].currentStreakString + &quot; Day Streak&quot;
      diditIcon.setImageDrawable(drawable)
      mainText.text = didit_tasks[position].mainText
      flavorText.text = didit_tasks[position].flavorText
      streakText.text = streakString
  }
  
  override fun getItemCount(): Int {
      return didit_tasks.size
  }
  
  class ViewHolder(val cardView: CardView) : RecyclerView.ViewHolder(
      cardView
  )
  </code></pre>
  <p>Update:</p>
  <p>It appears to be an issue not with my Recycler Views but with my Fragments. None of the fragments are loading up and I'm not sure why.</p>