app crashes on removeView

I wrote the following application where a 3 by 4 grid of buttons displayed and user can change the grid dimensions by clicking menu items. The problem is that something strange happens with the “…