Error inflating android.support.v17.leanback.widget.TitleView

2.6k views Asked by At

I'm testing the new support library leanback to design apps for TV, and i have a error ever android try to inflate the BrowseFragment and it throws this exception and don't know how to solve it. Thank you so much for your help.

android.view.InflateException: Binary XML file line #17: Error inflating class      android.support.v17.leanback.widget.TitleView
        at android.view.LayoutInflater.createView(LayoutInflater.java:620)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
        at android.view.LayoutInflater.parseInclude(LayoutInflater.java:816)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:745)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
        at android.support.v17.leanback.app.BrowseFragment.onCreateView(BrowseFragment.java:674)
        at android.app.Fragment.performCreateView(Fragment.java:1700)
        at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:866)
        at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1040)
        at android.app.FragmentManagerImpl.addFragment(FragmentManager.java:1142)
        at android.app.Activity.onCreateView(Activity.java:4828)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:689)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
        at com.engel.engeldroid.fragments.HomeFragment.onCreateView(HomeFragment.java:28)
        at android.app.Fragment.performCreateView(Fragment.java:1700)
        at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:890)
        at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1062)
        at android.app.BackStackRecord.run(BackStackRecord.java:684)
        at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1447)
        at android.app.FragmentManagerImpl$1.run(FragmentManager.java:443)
        at android.os.Handler.handleCallback(Handler.java:733)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:136)
        at android.app.ActivityThread.main(ActivityThread.java:5017)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:515)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:603)
        at dalvik.system.NativeStart.main(Native Method)

My xml:

<?xml version="1.0" encoding="utf-8"?>

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">


<fragment
    android:id="@+id/browse_fragment"
    android:name="android.support.v17.leanback.app.BrowseFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="New Button"
    android:id="@+id/button"
    android:layout_centerVertical="true"
    android:layout_centerHorizontal="true" />

1

There are 1 answers

0
Volodymyr On

As was mention in the comment the issue is related to the theme of the Activity in which leanback is used. Check if your activity uses Theme.Leanback theme directly in AndroidManifest

    <activity
        android:name=".YourActivity"
        android:theme="@style/Theme.Leanback" />

or your AppTheme derived from Theme.Leanback

 <style name="AppTheme" parent="Theme.Leanback" >
    // your custom attributes
 </style>