square / leakcanary

A memory leak detection library for Android.
https://square.github.io/leakcanary
Apache License 2.0
29.36k stars 3.97k forks source link

Crash and can't open #2689

Open ttooyy opened 3 months ago

ttooyy commented 3 months ago

Crash and can't open

E FATAL EXCEPTION: main Process: com.oplus.melody, PID: 16325 java.lang.IllegalStateException: countView must not be null at leakcanary.internal.activity.screen.LeaksScreen$onGroupsRetrieved$1.invoke(LeaksScreen.kt:57) at leakcanary.internal.activity.screen.LeaksScreen$onGroupsRetrieved$1.invoke(LeaksScreen.kt:24) at leakcanary.internal.activity.ui.SimpleListAdapter.getView(SimpleListAdapter.kt:19) at android.widget.AbsListView.obtainView(AbsListView.java:2482)

pyricau commented 3 months ago

Did this happen just once, or does it happen multiple times?

        val countView = view.findViewById<TextView>(R.id.leak_canary_count_text)
        val projection = projections[position]
        countView.isEnabled = projection.isNew

Looks like findViewById here returned null, which is unexpected as it's inflated from R.layout.leak_canary_leak_row which itself has this text view:

    <TextView
        android:id="@+id/leak_canary_count_text"
        android:layout_width="56dp"
        android:layout_height="56dp"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true"
        android:layout_marginLeft="20dp"
        android:background="@drawable/leak_canary_count_background"
        android:gravity="center"
        android:padding="16dp"
        android:textColor="@color/leak_canary_count_text"
        android:textSize="18sp"
        android:textStyle="bold"
        tools:text="1"
        />

Is there anything special going on with your build or your device? Can you reproduce this error on a sample project?