Backwards compatibility error inflating class.widget.button

624 views Asked by At

I have just finished my first app, and while it works on my nexus 5 (API 21), when i try to test it in older APIs it crashes after the splash screen (buttons are implemented), I use the AppCompat library and my styles and manifest is set properly. Please find attached part of my XML file as well my stacktrace. Any hings or suggestions on what is flawed is highly appreciated! Thanks a lot and in advance! PS.I tried to delete the buttons and it appears to work. Any hints?

layout.xml

<Button
    android:id="@+id/finalize"
    android:layout_width="160dp"
    android:layout_height="50dp"
    android:background="@drawable/finalize_button"
    android:text="@string/finalize_workout"
    android:textColor="#FFFFFF"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="40dp"
    android:visibility="gone"/>

<Button
    android:id="@+id/feedbackButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/myrect2"
    android:text="@string/feedback_button"
    android:textColor="@color/colorPrimaryDark"
    style="?android:attr/borderlessButtonStyle"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true"
    android:layout_marginTop="56dp"
    android:layout_marginRight="26dp"
    android:textSize="12sp"/>

finalize_button.xml drawable

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
           android:shape="rectangle">
        <solid android:color="@color/colorPrimary"/>
        <corners android:radius="6dp"/>
    </shape>
</item>
<item android:drawable="?android:selectableItemBackground"/>

stack trace

11-16 02:52:15.060    1844-1844/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.thanoschatz.quench/com.thanoschatz.quench.NewWorkoutActivity}: android.view.InflateException: Binary XML file line #53: Error inflating class android.widget.Button
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
        at android.app.ActivityThread.access$600(ActivityThread.java:130)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:137)
        at android.app.ActivityThread.main(ActivityThread.java:4745)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:511)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
        at dalvik.system.NativeStart.main(Native Method)
 Caused by: android.view.InflateException: Binary XML file line #53: Error inflating class android.widget.Button

 Caused by: java.lang.reflect.InvocationTargetException

 Caused by: android.content.res.Resources$NotFoundException: File res/drawable/finalize_button.xml from drawable resource ID #0x7f02003b

 Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #9: <item> tag requires a 'drawable' attribute or child tag defining a drawable
0

There are 0 answers