InflateException: Binary XML file line #1: Error inflating class <unknown> caused by OutOfMemoryError

Check your drawable/background_main i.e. the background image of your root layout - the VM runs out of memory when decoding the bitmap. Make the image dimensions smaller.


My problem was that I had a shape with a <solid> with color ?selectableItemBackground. Yes it is dumb and a specific case, but posting it here for people with the same mistake.


The problem occurs because the *drawable/background_main* has a high resolution image. So when it loads then the VM runs out of memory .

So best way is to reduce it size or resolution.