呈现问题java.lang.IllegalArgumentException:Android Studio中的导航抽屉预览中的java.lang.ClassCastException@47d5a628

时间:2019-06-15 11:14:26

标签: android android-studio android-layout

我在Android Studio 3.4中预览生成的导航抽屉布局时遇到问题。

这是activity_home.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout 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:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:openDrawer="start">

    <include
        layout="@layout/app_bar_home"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <com.google.android.material.navigation.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true"
        app:headerLayout="@layout/nav_header_home"
        app:menu="@menu/activity_home_drawer" />

</androidx.drawerlayout.widget.DrawerLayout>

我已经尝试了其他建议,但是没有一个与我遇到的问题相匹配。

我试图重新加载预览,清理,重建项目,但到目前为止,这些操作均无效。

我现在完全被困住了。

java.lang.IllegalArgumentException: java.lang.ClassCastException@47d5a628
    at sun.reflect.GeneratedMethodAccessor831.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at android.animation.PropertyValuesHolder_Delegate.callMethod(PropertyValuesHolder_Delegate.java:108)
    at android.animation.PropertyValuesHolder_Delegate.nCallFloatMethod(PropertyValuesHolder_Delegate.java:143)
    at android.animation.PropertyValuesHolder.nCallFloatMethod(PropertyValuesHolder.java)
    at android.animation.PropertyValuesHolder.access$400(PropertyValuesHolder.java:38)
    at android.animation.PropertyValuesHolder$FloatPropertyValuesHolder.setAnimatedValue(PropertyValuesHolder.java:1387)
    at android.animation.ObjectAnimator.animateValue(ObjectAnimator.java:990)
    at android.animation.ValueAnimator.setCurrentFraction(ValueAnimator.java:674)
    at android.animation.ValueAnimator.setCurrentPlayTime(ValueAnimator.java:637)
    at android.animation.ValueAnimator.start(ValueAnimator.java:1069)
    at android.animation.ValueAnimator.start(ValueAnimator.java:1088)
    at android.animation.ObjectAnimator.start(ObjectAnimator.java:852)
    at android.animation.StateListAnimator.start(StateListAnimator.java:188)
    at android.animation.StateListAnimator.setState(StateListAnimator.java:181)
    at android.view.View.drawableStateChanged(View.java:21105)
    at android.view.ViewGroup.drawableStateChanged(ViewGroup.java:7101)
    at com.google.android.material.appbar.AppBarLayout.drawableStateChanged(AppBarLayout.java:393)
    at android.view.View.refreshDrawableState(View.java:21160)
    at android.view.View.dispatchAttachedToWindow(View.java:18379)
    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3397)
    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3404)
    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3404)
    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3404)
    at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3404)
    at android.view.AttachInfo_Accessor.setAttachInfo(AttachInfo_Accessor.java:42)
    at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:335)
    at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:391)
    at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:195)
    at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:540)
    at com.android.tools.idea.rendering.RenderTask.lambda$inflate$5(RenderTask.java:666)
    at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1590)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

2 个答案:

答案 0 :(得分:0)

我遇到了类似的问题,并将Studio更新到3.4.2可以解决此问题。

答案 1 :(得分:0)

您是否尝试过文件→“使缓存无效/重新启动”?

请注意,可能需要一段时间才能重新启动。