I am trying to get my layout working that would be implementing the support design library features. However when I try running the project I am getting following exception when my layout is being loaded.
Android.Views.InflateException: Binary XML file line #2: Error inflating class android.support.design.widget.CollapsingToolbarLayout
Here is my layout:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- As the main content view, the view below consumes the entire
space available using match_parent in both dimensions. -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/main_grey">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:layout_height="192dp"
android:layout_width="match_parent">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll"
>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="60dp"
android:minHeight="60dp"
android:background="@drawable/actionbar_background">
<ImageView
android:id="@+id/psonar_logo"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="top|center_horizontal"
android:visibility="gone" />
<RelativeLayout
android:id="@+id/toolbarTitles"
android:layout_alignParentLeft="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone">
<TextView
android:id="@+id/toolbarTitle"
android:ellipsize="end"
android:maxLines="1"
android:textSize="18dp"
android:textColor="@color/white"
android:layout_alignParentLeft="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/toolbarSubtitle"
android:ellipsize="end"
android:maxLines="1"
android:textColor="@color/white"
android:gravity="center_vertical"
android:visibility="gone"
android:layout_alignParentLeft="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/toolbarTitle" />
</RelativeLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="@+id/scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<FrameLayout
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="175dp"
android:id="@+id/carouselFrameLayout" />
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/toolbar"
android:layout_above="@id/miniPlayerHolder"
android:background="@color/main_grey"
android:animateLayoutChanges="true"
android:orientation="vertical">
<TabHost
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="45dp"
android:tabStripEnabled="false"
android:layout_weight="0"
android:showDividers="none" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="0" />
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
</TabHost>
</LinearLayout>
<include
layout="@layout/mini_player_holder" />
</RelativeLayout>
<!-- android:layout_gravity="start" tells DrawerLayout to treat
this as a sliding drawer on the left side for left-to-right
languages and on the right side for right-to-left languages.
The drawer is given a fixed width in dp and extends the full height of
the container. A solid background is used for contrast
with the content view. -->
<include
layout="@layout/home_drawer_menu" />
</android.support.v4.widget.DrawerLayout>
I tried building simple test project that was implementing the CollapsingToolbarLayout and it worked without any issues but as soon as I try putting it into my project it stops working.
I checked nuget packages and they seem to be installed fine. Our theme is inheriting from: Theme.AppCompat.NoActionBar.
Stacktrace:
{Android.Views.InflateException: Exception of type 'Android.Views.InflateException' was thrown. at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in /Users/builder/data/lanes/2185/53fce373/source/mono/mcs/class/corlib/System.Runtime.ExceptionServices/ExceptionDispatchInfo.cs:61 at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (intptr,intptr,intptr,Android.Runtime.JValue*) [0x00084] in /Users/builder/data/lanes/2185/53fce373/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:1029 at Android.App.Activity.SetContentView (int) [0x00070] in /Users/builder/data/lanes/2185/53fce373/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.App.Activity.cs:5872 at Psonar.Apps.Droid.PayPerPlay.HomeActivity.OnCreate (Android.OS.Bundle) [0x00009] in E:\Dev\psonar\Source\Psonar.Apps\Psonar.Apps.Droid\Psonar.Apps.Droid.PayPerPlay\UI\HomeActivity.cs:66 at Android.Support.V4.App.FragmentActivity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) at (wrapper dynamic-method) object.14ce2242-aa35-41bb-a113-286527a98d77 (intptr,intptr,intptr)
--- End of managed exception stack trace --- android.view.InflateException: Binary XML file line #2: Error inflating class android.support.design.widget.CollapsingToolbarLayout at android.view.LayoutInflater.createView(LayoutInflater.java:633) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743) at android.view.LayoutInflater.rInflate(LayoutInflater.java:806) at android.view.LayoutInflater.rInflate(LayoutInflater.java:809) at android.view.LayoutInflater.rInflate(LayoutInflater.java:809) at android.view.LayoutInflater.rInflate(LayoutInflater.java:809) at android.view.LayoutInflater.inflate(LayoutInflater.java:504) at android.view.LayoutInflater.inflate(LayoutInflater.java:414) at android.view.LayoutInflater.inflate(LayoutInflater.java:365) at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:255) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109) at md5cdb4fd1f07f997be815955fad4cc2feb.HomeActivity.n_onCreate(Native Method) at md5cdb4fd1f07f997be815955fad4cc2feb.HomeActivity.onCreate(HomeActivity.java:38) at android.app.Activity.performCreate(Activity.java:5990) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) at android.app.ActivityThread.access$800(ActivityThread.java:151) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5254) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.newInstance(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:288) at android.view.LayoutInflater.createView(LayoutInflater.java:607) ... 25 more Caused by: java.lang.NoSuchFieldError: No static field TextAppearance_android_shadowColor of type I in class Landroid/support/design/R$styleable; or its superclasses (declaration of 'android.support.design.R$styleable' appears in /data/app/com.psonar.android-1/base.apk) at android.support.design.widget.CollapsingTextHelper.setExpandedTextAppearance(CollapsingTextHelper.java:230) at android.support.design.widget.CollapsingToolbarLayout.(CollapsingToolbarLayout.java:185) at android.support.design.widget.CollapsingToolbarLayout.(CollapsingToolbarLayout.java:126) ... 28 more }
CollapsingToolbarLayout
is not onBinary XML file line #2
in that file. Inspect your stacktrace, and see what class is trying to inflate the problematic layout. – Mike M.HomeActivity
, I guess that must be it. Maybe Xamarin compiles its resource files differently. – Mike M.