1

I get the following error in the Preview window for Android layouts:

Rendering Problems Rendering failed with a known bug. Please try a rebuild.  The following classes could not be instantiated:
- android.support.v7.widget.Toolbar (Open Class, Show Exception, Clear Cache)

 Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE  Exception Details 

java.lang.NoSuchFieldError: abc_ratingbar_indicator_material   at 
android.support.v7.widget.AppCompatDrawableManager.tintDrawable(AppCompatDrawableManager.java:222)   at
android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:184)   at 
android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:173)   at 
android.support.v7.widget.TintTypedArray.getDrawable(TintTypedArray.java:60)   at
android.support.v7.widget.Toolbar.<init>(Toolbar.java:254)   at 
android.support.v7.widget.Toolbar.<init>(Toolbar.java:196)   at 
java.lang.reflect.Constructor.newInstance(Constructor.java:526)   at 
android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:806)   at 
android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)   at
 android.view.LayoutInflater.rInflate(LayoutInflater.java:782)   at android.view.LayoutInflater.inflate(LayoutInflater.java:504)   at 
android.view.LayoutInflater.inflate(LayoutInflater.java:385) Copy stack to clipboard

I have the following

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <android.support.v7.widget.Toolbar
        android:id="@+id/activity_action_toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/primary_color"
        app:contentInsetEnd="0dp"
        app:contentInsetStart="0dp"
        android:elevation="4dp"
        android:fitsSystemWindows="true"
        app:navigationIcon="@drawable/abc_ic_ab_back_material"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
        app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        android:transitionName="@string/transition_key_action">

            <LinearLayout
                android:id="@+id/actvity_action_focus_placeholder"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:layout_marginTop="56dp"
                android:layout_marginLeft="16dp"
                android:descendantFocusability="beforeDescendants"
                android:focusableInTouchMode="true"
                android:paddingBottom="6dp">

                <EditText
                    android:id="@+id/activity_action_name_edittext"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="@string/createaction_name_placeholder"
                    android:layout_marginRight="16dp"
                    android:imeOptions="actionDone"
                    android:singleLine="true"
                    android:ellipsize="none"
                    android:inputType="text"
                    android:textSize="22sp"
                    android:textColor="#fff"
                    android:focusable="true"
                    android:background="@android:color/transparent"
                    android:transitionName="@string/transition_key_action_name"/>

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:textAppearance="?android:attr/textAppearanceSmall"
                    android:text="Från: [Möte] (Datum)"
                    android:id="@+id/activity_action_meetingdate"
                    android:textColor="#fff"
                    android:layout_marginBottom="6dp"
                    android:layout_marginRight="16dp"
                    android:transitionName="@string/transition_key_action_date"/>

            </LinearLayout>

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

    <android.support.v4.widget.SwipeRefreshLayout
        android:id="@+id/activity_action_swipe_refresh_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        tools:context=".Activities.ActionActivity">

            <android.support.v7.widget.RecyclerView
                android:id="@+id/activity_action_recyclerview"
                android:scrollbars="vertical"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:descendantFocusability="beforeDescendants"/>

    </android.support.v4.widget.SwipeRefreshLayout>

</LinearLayout>

I have following in my Gradle files :

classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'com.google.gms:google-services:1.4.0-beta3'

..

compile 'com.android.support:design:23.2.0'
compile 'com.mcxiaoke.volley:library:1.0.16'
compile 'com.android.support:cardview-v7:23.2.0'
compile 'com.android.support:recyclerview-v7:23.2.0'
compile 'com.prolificinteractive:material-calendarview:0.8.0'
compile 'net.hockeyapp.android:HockeySDK:3.5.0'
compile 'com.google.code.gson:gson:1.7.2'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.google.android.gms:play-services-analytics:8.1.0'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.android.support:support-v4:23.2.0'

My styles.xml:

<resources>
    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="colorControlNormal">@color/secondary_text</item>
        <item name="colorControlActivated">@color/accent_color</item>
        <item name="colorControlHighlight">@color/secondary_text</item>
        <item name="colorPrimary">@color/primary_color</item>
        <item name="colorPrimaryDark">@color/dark_primary_color</item>
        <item name="colorAccent">@color/accent_color</item>

        <item name="android:windowActionModeOverlay">true</item>
        <item name="windowActionModeOverlay">true</item>
        <item name="android:actionModeBackground">@color/dark_primary_color</item>

    </style>

I have tried to change to Base.Theme.AppCompat.Light.NoActionBar but it does not exist. I have tried changing to compile 'com.android.support:design:23.2.0', switch API level in the Preview, rebuilding, invalidating cache et.c.

Any ideas?

Sunkas
  • 9,542
  • 6
  • 62
  • 102
  • Post the code to your styles.xml file as well, as the theme that you've set matters the most. And your MainActivity class or whichever activity which is using ToolBar should be extending AppCompatActivity instead of Activity – Aman Grover Mar 02 '16 at 16:47
  • [The following classes could not be instantiated: - android.support.v7.widget.Toolbar](https://stackoverflow.com/q/26575815/6521116) – LF00 Jul 11 '17 at 09:52
  • I solve it with [this answer](https://stackoverflow.com/a/30749068/6521116) – LF00 Jul 11 '17 at 10:03

2 Answers2

0

I think this is fixed in support 23.3.0, at least it fixed it for me.

Frank
  • 12,010
  • 8
  • 61
  • 78
0

After upgrading to the support library (23.3.0) it happened to me as well. Clean and rebuild resolved the issue.

Oguz Ozcan
  • 1,694
  • 19
  • 26