butterknife icon indicating copy to clipboard operation
butterknife copied to clipboard

Bind cannot find required view in some circumstances in Android 8.0

Open kschwall opened this issue 6 years ago • 3 comments

I've been using butterknife for a while now without much issue, but recently I've encountered a frankly bizarre error that I haven't been able to find anything on elsewhere. I'm seeing a sudden upswing in crashes caused by 'required view with ID X was not found' exceptions.

In and of itself, that's no big deal, but the strangeness comes in that the view definitively exists in the view hierarchy. It's a sporadic issue that only occurs occasionally, and only on 8.0 devices.

The context here is that I have a parent Activity class with shared functionality and UI elements, which overrides the setContentView method and inserts whatever layout the child Activity attempts to use into the appropriate portion of the shared layout, like so:

@Override
public void setContentView(int child_layout){
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View roott = inflater.inflate(R.layout.base_activity, null, false);
    inflater.inflate(child_layout, (FrameLayout) root.findViewById(R.id.container), true);
    super.setContentView(root);
    ButterKnife.bind(this);
}

It's crashing on the bind here, attempting to find one of the elements of the base_activity layout, which is not present in child_layout.

I am using ButterKnife 8.8.1, and it works fine for all other versions of Android and, most of the time, for Android 8.0 as well. Is there anything that can be done to resolve this?

kschwall avatar Sep 07 '18 18:09 kschwall

I am having a similar issue, however this effects me only on android tablets, and doesn't matter on which android version

jreynolds1998 avatar Sep 24 '18 02:09 jreynolds1998

I have the same issue for version 10.1.0

ProgrammerBill avatar Feb 19 '19 16:02 ProgrammerBill

I have the same issue for version 10.1.0 on android tablets too,

SpannerBear avatar Dec 06 '19 08:12 SpannerBear