Reputation: 34780
I'm calling findViewById
and Android Studio (version 3.1, stable) prompts me to put an assertion:
When I select it, it adds the following line above the selected line:
assert v != null;
Great. I run the app, and the View v
is null. However, assertion doesn't work and it jumps to the line below it in debugger:
How is this even possible? It was Android Studio's own suggestion, and I didn't change a thing. Its own recommendation/autogenerated code is not working. Am I missing something obvious?
Upvotes: 2
Views: 1930
Reputation: 34780
Apparently, (as stated in the comments) assertions are disabled by default but encouraged by Android Studio.
In this manner, the "problem" can be classified as a misleading UX issue rather than a technical problem.
Upvotes: 3