The !! is the only way you can get a KotlinNullPointerException. The exception means your assertion that the item is non-null is wrong. In this case, it means a view with that ID does not exist in the dialog layout you have set.

Maybe the view you are looking for is in the activity layout, in which case you should call this.findViewById instead of myDialog.findViewById.

Otherwise, check your dialog layout closely to make sure it is there. If you have multiple versions of the layout for different configurations, make sure they all have a view with that ID.

You might want to look into view binding, which is designed to avoid this kind of problem.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top