For me, inside one of my layout.xml files, I had
<ImageView
android:id="@+id/row_1_col_0"
android:layout_width="@string/default_picture_size"
android:layout_height="@string/default_picture_size"
android:layout_weight="1"
android:background="@drawable/tile"
android:onClick="mClickMethod" >
</ImageView>
and inside strings.xml, I had
wrap_content
and so it was showing this in Android Studio:
<ImageView
android:id="@+id/row_1_col_0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/tile"
android:onClick="mClickMethod" >
</ImageView>
I thought everything would work because there were no errors and the application compiled and ran. However, there was a run time error that said I didn't set the layout_width.
Once I changed layout_width and layout_height from:
android:layout_width="@string/default_picture_size"
android:layout_height="@string/default_picture_size"
to
android:layout_width="wrap_content"
android:layout_height="wrap_content"
everything worked.