我在Android布局的预览窗口中收到以下错误:
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
我有以下
<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>
我在Gradle文件中有以下内容:
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'
我的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>
我尝试更改为Base.Theme.AppCompat.Light.NoActionBar
,但它不存在。我已尝试更改为compile 'com.android.support:design:23.2.0'
,在预览中切换API级别,重建,使缓存等无效。
有什么想法吗?
答案 0 :(得分:0)
我认为这已经在支持23.3.0中修复,至少它已经为我修复了。
答案 1 :(得分:0)
升级到支持库(23.3.0)后,它也发生在我身上。清理和重建解决了这个问题。