I have an Android app that is recently published, and I'm receiving crash reports from Google Play Console. One of the crashes is strange. It happens in code similar to the following:
private final List<Item> items = new ArrayList<>();
public void addItem(Item item) {
items.add(item); // NullPointerException here!!
}
Apparently items
is null when addItem
is called, but it seems to me that it's impossible—I've initialized it at the declaration site. I can't imagine a situation in which this could happen, yet it happens a lot. Any idea?