XML : Android VM crashes when loading XML file of Main Activity

It used to work properly until we added custom images for all the ImageButtons. There are litterally 6 little .png images to load (a total size of ~100kb). If we were to put 3 same images (e.g. ImageButtons 1,2,3 have the same image and other 3 have their own) it actually works. We've deduced that the problem is with the number of images, but we do not know how to fix this.

Error:

Process: com.example.user.appname, PID: 2424 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.user.appname/com.example.user.appname.MainActivity}: android.view.InflateException: Binary XML file line #106: Binary XML file line #106: Error inflating class

Here is the XML file:

  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"  xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"  android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"  xmlns:ads="http://schemas.android.com/apk/res-auto"  android:paddingRight="@dimen/activity_horizontal_margin"  android:paddingTop="@dimen/activity_vertical_margin"  tools:context=".MainActivity"  android:id="@+id/activity_main"  android:background="#2390ce">      <LinearLayout      android:orientation="vertical"      android:layout_width="match_parent"      android:layout_height="match_parent"      android:background="@drawable/mainbackground">        <LinearLayout          android:orientation="horizontal"          android:layout_width="match_parent"          android:layout_height="0px"          android:layout_weight="0.4"          android:background="@drawable/banner">            <RelativeLayout              android:orientation="horizontal"              android:layout_width="match_parent"              android:layout_height="match_parent">                <ImageView                  android:layout_width="30dp"                  android:layout_height="30dp"                  android:id="@+id/tokenImageView"                  android:src="@drawable/goldtoken"                  android:layout_centerVertical="true"/>                <TextView                  android:layout_width="wrap_content"                  android:layout_height="wrap_content"                  android:textSize="30dp"                  android:text="@string/zero"                  android:id="@+id/tokenNumberTextView"                  android:layout_centerInParent="true"/>          </RelativeLayout>        </LinearLayout>        <LinearLayout          android:orientation="horizontal"          android:layout_width="match_parent"          android:layout_height="0px"          android:layout_weight="1"          android:baselineAligned="false">            <LinearLayout              android:orientation="horizontal"              android:layout_width="0px"              android:layout_height="match_parent"              android:layout_weight="1">                <RelativeLayout                  android:layout_width="match_parent"                  android:layout_height="match_parent">                    <ImageButton                      android:layout_width="90dp"                      android:layout_height="90dp"                      android:id="@+id/statsButton"                      android:layout_marginLeft="35dp"                      android:layout_marginStart="35dp"                      android:layout_centerInParent="true"                      android:background="@drawable/stats" />                </RelativeLayout>          </LinearLayout>            <LinearLayout              android:orientation="horizontal"              android:layout_width="0px"              android:layout_height="match_parent"              android:layout_weight="1">                <RelativeLayout                  android:layout_width="match_parent"                  android:layout_height="match_parent">                    <ImageButton                      android:layout_width="90dp"                      android:layout_height="90dp"                      android:id="@+id/achievementsButton"                      android:layout_centerInParent="true"                      android:background="@drawable/star" />              </RelativeLayout>          </LinearLayout>      </LinearLayout>        <LinearLayout          android:orientation="horizontal"          android:layout_width="match_parent"          android:layout_height="0px"          android:layout_weight="1.7">            <RelativeLayout              android:layout_width="match_parent"              android:layout_height="match_parent">                <ImageButton                  android:layout_width="150dp"                  android:layout_height="150dp"                  android:id="@+id/playButton"                  android:layout_centerInParent="true"                  android:contentDescription="@string/play"                  android:background="@drawable/play" />          </RelativeLayout>      </LinearLayout>        <LinearLayout          android:orientation="horizontal"          android:layout_width="match_parent"          android:layout_height="0px"          android:layout_weight="1"          android:baselineAligned="false">            <LinearLayout              android:orientation="horizontal"              android:layout_width="0px"              android:layout_height="match_parent"              android:layout_weight="1">                <RelativeLayout                  android:layout_width="match_parent"                  android:layout_height="match_parent">                    <ImageButton                      android:layout_width="90dp"                      android:layout_height="90dp"                      android:id="@+id/aboutButton"                      android:layout_centerInParent="true"                      android:contentDescription="@string/about"                      android:background="@drawable/info">                  </ImageButton>              </RelativeLayout>          </LinearLayout>            <LinearLayout              android:orientation="horizontal"              android:layout_width="0px"              android:layout_height="match_parent"              android:layout_weight="1">                <RelativeLayout                  android:layout_width="match_parent"                  android:layout_height="match_parent">                    <ImageButton                      android:layout_width="90dp"                      android:layout_height="90dp"                      android:id="@+id/suggestionButton"                      android:layout_centerInParent="true"                      android:contentDescription="@string/suggestion"                      android:background="@drawable/feedback" />              </RelativeLayout>          </LinearLayout>      </LinearLayout>        <LinearLayout          android:orientation="horizontal"          android:layout_width="match_parent"          android:layout_height="0px"          android:layout_weight="0.38">            <RelativeLayout              android:layout_width="match_parent"              android:layout_height="match_parent">                <com.google.android.gms.ads.AdView                  android:id="@+id/adView"                  android:layout_width="wrap_content"                  android:layout_height="wrap_content"                  ads:adSize="BANNER"                  ads:adUnitId="@string/banner_ad_unit_id"                  android:layout_centerHorizontal="true">              </com.google.android.gms.ads.AdView>            </RelativeLayout>      </LinearLayout>    </LinearLayout>    

No comments:

Post a Comment