androidlayoutgalaxy-nexus

Android : Galaxy Nexus GT-I9250 crashes on my Layout


I have a LinearLayout that works like a Charm on most devices

but I get this error every time I run this app on Galaxy Nexus GT-I9250

    android.view.InflateException: Binary XML file line #130: Error inflating class <unknown>
    at android.view.LayoutInflater.createView(LayoutInflater.java:621)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:756)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:759)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:759)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:759)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:397)

I tried to do some digging to figure out the problem. But nothing worked.

This is my layout :

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:weightSum="10">

    <android.support.v7.widget.LinearLayoutCompat
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="2"
        android:gravity="center"
        android:layout_marginTop="30dp"
        android:orientation="horizontal">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp"
            android:text="@string/settings_title"/>
    </android.support.v7.widget.LinearLayoutCompat>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:orientation="vertical"
        android:layout_weight="8">

    <android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        app:cardCornerRadius="8dp"
        android:layout_marginBottom="5dp"
        android:layout_marginLeft="12dp"
        android:layout_marginRight="12dp"
        app:cardBackgroundColor="@color/hmBG">

        <android.support.v7.widget.LinearLayoutCompat
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:orientation="horizontal">


            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/selectCountry" />
            <android.support.v7.widget.AppCompatSpinner
                android:id="@+id/userCountry"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content">

            </android.support.v7.widget.AppCompatSpinner>
        </android.support.v7.widget.LinearLayoutCompat>
    </android.support.v7.widget.CardView>

    <android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        app:cardCornerRadius="8dp"
        android:layout_marginBottom="10dp"
        android:layout_marginLeft="12dp"
        android:layout_marginRight="12dp"
        app:cardBackgroundColor="@color/hmBG"
        >
        <android.support.v7.widget.LinearLayoutCompat
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="10dp"
            android:gravity="center"
            android:orientation="vertical">
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="start"
                android:text="@string/textStringET"
                android:layout_marginRight="12dp"
                android:layout_marginLeft="12dp"
                />

            <android.support.v7.widget.LinearLayoutCompat
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">

                <android.support.v7.widget.AppCompatEditText
                    android:id="@+id/userTextET"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="@string/testHint"/>
                <android.support.v7.widget.AppCompatTextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/providerFormatExample"/>
            </android.support.v7.widget.LinearLayoutCompat>
        </android.support.v7.widget.LinearLayoutCompat>
    </android.support.v7.widget.CardView>

    <android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        app:cardCornerRadius="8dp"
        android:layout_marginBottom="10dp"
        android:layout_marginLeft="12dp"
        android:layout_marginRight="12dp"
        app:cardBackgroundColor="@color/hmBG"
        >
        <android.support.v7.widget.LinearLayoutCompat
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="10dp"
            android:gravity="center"
            android:orientation="vertical">
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="start"
                android:text="@string/testTextTV"
                android:layout_marginRight="12dp"
                android:layout_marginLeft="12dp"
                />

            <android.support.v7.widget.LinearLayoutCompat
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">

                <android.support.v7.widget.AppCompatEditText
                    android:id="@+id/testInputET"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content" />
                <android.support.v7.widget.AppCompatTextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:textDirection="firstStrongLtr"
                    android:text="@string/stringExample"/>
            </android.support.v7.widget.LinearLayoutCompat>
        </android.support.v7.widget.LinearLayoutCompat>
    </android.support.v7.widget.CardView>

    <android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        app:cardCornerRadius="8dp"
        android:layout_marginBottom="10dp"
        android:layout_marginLeft="12dp"
        android:layout_marginRight="12dp"
        app:cardBackgroundColor="@color/hmBG"
        >
        <android.support.v7.widget.LinearLayoutCompat
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:layout_marginTop="12dp"
            android:padding="10dp"
            android:orientation="vertical">
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="start"
                android:text="@string/settingMode"
                android:layout_marginRight="12dp"
                android:layout_marginLeft="12dp"
                />


            <RadioGroup
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="horizontal">


                <android.support.v7.widget.AppCompatRadioButton
                    android:id="@+id/firstRB"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:paddingLeft="4dp"
                    android:paddingRight="4dp"
                    android:text="@string/fText_string" />


                <android.support.v7.widget.AppCompatRadioButton
                    android:id="@+id/secRB"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="12dp"
                    android:layout_marginRight="12dp"
                    android:paddingLeft="4dp"
                    android:paddingRight="4dp"
                    android:text="@string/txt_string" />




            </RadioGroup>
        </android.support.v7.widget.LinearLayoutCompat>
    </android.support.v7.widget.CardView>

    <android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        app:cardCornerRadius="8dp"
        android:layout_marginBottom="10dp"
        android:layout_marginLeft="12dp"
        android:layout_marginRight="12dp"
        app:cardBackgroundColor="@color/hmBG"
        >
        <android.support.v7.widget.LinearLayoutCompat
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:layout_marginTop="12dp"
            android:padding="10dp"
            android:orientation="vertical">
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="start"
                android:text="@string/alertEffects"
                android:layout_marginRight="12dp"
                android:layout_marginLeft="12dp"
                />
            <android.support.v7.widget.LinearLayoutCompat
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="horizontal">
                <android.support.v7.widget.SwitchCompat
                    android:id="@+id/switch1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/sound_switch_txt" />

                <android.support.v7.widget.SwitchCompat
                    android:id="@+id/switch2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/vibrate_switch_txt" />
            </android.support.v7.widget.LinearLayoutCompat>

        </android.support.v7.widget.LinearLayoutCompat>
    </android.support.v7.widget.CardView>
    </LinearLayout>

</android.support.v7.widget.LinearLayoutCompat> 

I'm using ViewPager with Two Fragments.

I'm extending the Fragment with v4 support.


Solution

  • i finally fixed it by replacing this attribute:

    android:textDirection="firstStrongLtr"
    

    with :

    android:textDirection="anyRtl"
    

    now everything works perfectly!