App crashing when using android data-binding on android 8 App crashing when using android data-binding on android 8 android android

App crashing when using android data-binding on android 8


Have similar crashes with exactly the same stacktrace on 8.

Have you tried using:

binding = DataBindingUtil.inflate(getLayoutInflater(), R.layout.activity, null, false);setContentView(binding.getRoot());

Difference between code above and calling

DataBindingUtil.setContentView(...);

is that inflate() returns a View directly which is later passed to DataBindingUtils::bindToAddedViews.In case of DataBindingUtil.setContentView the following logic is being used

activity.setContentView(layoutId);View decorView = activity.getWindow().getDecorView();ViewGroup contentView = (ViewGroup) decorView.findViewById(android.R.id.content);

and it seems that

ViewGroup contentView = (ViewGroup) decorView.findViewById(android.R.id.content);

is just NULL...