admin管理员组

文章数量:1550365

Why does Android Studio indicate that an object might be null when it cannot be?

Because lint cannot know. document.exists() can return null in general and that's why you see the warning. Lint performs basic checks and doesn't know the details about the Firebase API. You can even reproduce this behaviour with the Java Core API.

How can I solve this without checking for nullity? Thanks!

If you are 100% sure that it can never be null, you can use

@SuppressWarnings("ConstantConditions")

But I would not recommend that, because you don't know if the Firebase API will change in the future. Maybe the next version of Firebase will allow null returns.

本文标签: androidStudionullobject