2

While running on Android version 8.1.0 it is ok, but in android version 6.0.1 it throws this exception.

My code is

<Button
   android:id="@+id/signin"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:layout_marginLeft="14dp"
   android:layout_marginTop="@dimen/button_top_margin"
   android:layout_marginRight="14dp"
   android:background="@drawable/button_background_orange"
   android:text="@string/action_sign_in"
   android:textColor="@color/colorText" />

button_background_orange.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#F29439" />
<corners android:radius="25dp" />
<stroke
    android:width="1dp"
    android:color="#F29439" />
</shape>

exception:

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.dinesh.kumarijobemployer, PID: 22475
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.dinesh.kumarijobemployer/com.dinesh.kumarijobemployer.LoginActivity}: android.view.InflateException: Binary XML file line #132: Binary XML file line #132: Error inflating class Button
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3253)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349)
    at android.app.ActivityThread.access$1100(ActivityThread.java:223)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:7223)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
 Caused by: android.view.InflateException: Binary XML file line #132: Binary XML file line #132: Error inflating class Button
    at android.view.LayoutInflater.inflate(LayoutInflater.java:551)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:380)
Dinesh Sarma
  • 461
  • 3
  • 14
  • Hi, you say your app has thrown an exception, but you've not said what that exception is other than the one line in the title. Could you please post your logcat stacktrace? – Michael Dodd Feb 05 '19 at 07:55
  • 2
    Check `button_background_orange` file in all drawable folders . Specially in default one . Looks like you have it only under `drawable-v24`. – ADM Feb 05 '19 at 07:56
  • its RuntimeException @Michael Dodd – Dinesh Sarma Feb 05 '19 at 08:01
  • Thank you sir @ADM...there is only drawable-v24 and after creating another one drawable-v21 it workd – Dinesh Sarma Feb 05 '19 at 08:10
  • You need to add it to default drawable too(otherwise it will crash under 21 if your minsdk is below 21) . If it does not include `ripple` or any API level dependent effect then just use it in default `drawable` only. – ADM Feb 05 '19 at 08:17
  • ok and thak you once again @ADM – Dinesh Sarma Feb 05 '19 at 09:07

0 Answers0