Search code examples
androidtabletseekbarinflate-exception

android.view.InflateException: Binary XML file line #39: Error inflating class ProgressWidget


public final class ProgressWidget extends LinearLayout {

    <Default Constructors implemented> {
        setOrientation(LinearLayout.VERTICAL);
        inflate(context, R.layout.horizontal_progress, this);
    }

    @Override
    protected void onFinishInflate() {
        //Continue with rest of the logic.
    }
}

R.layout.horizontal_progress has 35 lines.

<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android">

<TextView
    android:id="@+id/progressTextView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/rounded_white_background"
    android:gravity="center"
    android:textColor="@color/light_black"
    android:textSize="12sp"
    android:fontFamily="roboto-regular"
    android:paddingTop="1dp"
    android:paddingBottom="1dp"
    android:paddingLeft="2dp"
    android:paddingRight="2dp" />

<SeekBar
    android:id="@+id/progress"
    android:layout_width="match_parent"
    android:layout_height="@dimen/horizontal_progress_height"
    android:indeterminate="false"
    android:progressDrawable="@drawable/horizontal_progress"
    android:gravity="center"
    android:thumb="@null"
    android:progress="0"
    android:secondaryProgress="0"
    android:max="100"
    android:minHeight="@dimen/horizontal_progress_height"
    android:paddingTop="1dp"
    android:paddingBottom="1dp"
    android:paddingLeft="2dp"
    android:paddingRight="2dp" />

</merge>

R.drawable.horizontal_progress has 36 lines.

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">
<item android:id="@android:id/background">
    <shape android:shape="rectangle" >
        <corners android:radius="@dimen/horizontal_progress_radius" />
        <gradient
            android:startColor="@color/horizontal_progress_background"
            android:endColor="@color/horizontal_progress_background"
            android:angle="270"/>
    </shape>
</item>
<item android:id="@android:id/secondaryProgress">
    <clip>
        <shape android:shape="rectangle" >
            <corners android:radius="@dimen/horizontal_progress_radius" />
            <gradient
                android:startColor="@android:color/white"
                android:endColor="@android:color/white"
                android:angle="270"/>
        </shape>
    </clip>
</item>
<item android:id="@android:id/progress">
    <clip>
        <shape android:shape="rectangle" >
            <corners android:radius="@dimen/horizontal_progress_radius" />
            <gradient
                android:startColor="?android:attr/colorAccent"
                android:endColor="?android:attr/colorAccent"
                android:angle="270"
                tools:ignore="NewApi"/>
        </shape>
    </clip>
</item>
</layer-list>

Last segment of the Stack-trace.

Caused by: android.view.InflateException: Binary XML file line #39: Error inflating class ProgressWidget at android.view.LayoutInflater.createView(LayoutInflater.java:620) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696) at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) at android.view.LayoutInflater.rInflate(LayoutInflater.java:758) at android.view.LayoutInflater.inflate(LayoutInflater.java:462) at android.view.LayoutInflater.inflate(LayoutInflater.java:397) at android.view.LayoutInflater.inflate(LayoutInflater.java:353) at android.view.View.inflate(View.java:1746

Everything works right on Phone Device - Samsung Galaxy S5 SM-G900A, Android Version 5.0. Always crashing with above stack-trace on Asus Nexus 7, Android 4.4.3.

This ProgressWidget is a custom reusable component of an Android Library module, that will be used with a Project Module. The main Project Module is expected to cater minSDKVersion 16 all the way up to TargetSDKVersion 24.

Any pointers as to what may be causing the crash only on Tablet device will be greatly appreciated.


Solution

  • I managed to resolve this issue based off another similar issue.

    https://stackoverflow.com/a/39254876/941912