java.lang.ClassNotFoundException:android.view.View $ OnUnhandledKeyEventListener

时间:2018-08-23 15:53:15

标签: android event-listener

当我尝试将图像视图添加到Android Studio的布局编辑器时,它没有显示,并且还显示了一些错误

this is the error showing in the android studio

  

Java

java.lang.ClassNotFoundException: android.view.View$OnUnhandledKeyEventListener
    at org.jetbrains.android.uipreview.ModuleClassLoader.load(ModuleClassLoader.java:180)
    at com.android.tools.idea.rendering.RenderClassLoader.findClass(RenderClassLoader.java:61)
    at org.jetbrains.android.uipreview.ModuleClassLoader.findClass(ModuleClassLoader.java:118)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at org.jetbrains.android.uipreview.ModuleClassLoader.loadClass(ModuleClassLoader.java:213)
    at android.support.v7.widget.GridLayout.isLayoutRtlCompat(GridLayout.java:679)
    at android.support.v7.widget.GridLayout.onLayout_Original(GridLayout.java:1082)
    at android.support.v7.widget.GridLayout.onLayout(GridLayout.java)
    at android.view.View.layout_Original(View.java:19659)
    at android.view.View_Delegate.layout(View_Delegate.java:91)
    at android.view.View.layout(View.java:19645)
    at android.view.ViewGroup.layout(ViewGroup.java:6075)
    at android.support.constraint.ConstraintLayout.onLayout_Original(ConstraintLayout.java:1858)
    at android.support.constraint.ConstraintLayout.onLayout(ConstraintLayout.java)
    at android.view.View.layout_Original(View.java:19659)
    at android.view.View_Delegate.layout(View_Delegate.java:91)
    at android.view.View.layout(View.java:19645)
    at android.view.ViewGroup.layout(ViewGroup.java:6075)
    at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
    at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
    at android.view.View.layout_Original(View.java:19659)
    at android.view.View_Delegate.layout(View_Delegate.java:91)
    at android.view.View.layout(View.java:19645)
    at android.view.ViewGroup.layout(ViewGroup.java:6075)
    at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1083)
    at android.view.View.layout_Original(View.java:19659)
    at android.view.View_Delegate.layout(View_Delegate.java:91)
    at android.view.View.layout(View.java:19645)
    at android.view.ViewGroup.layout(ViewGroup.java:6075)
    at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:346)
    at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:384)
    at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:193)
    at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:544)
    at com.android.tools.idea.rendering.RenderTask.lambda$inflate$3(RenderTask.java:678)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    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)

它显示UnhandledKeyEventListener错误

2 个答案:

答案 0 :(得分:4)

在您的 build.gradle(应用级别)中进行更改,以将其降级到以下版本27。然后同步并构建项目。希望它将解决该问题。

compileSdkVersion 27

targetSdkVersion 27

实现'com.android.support:appcompat-v7:27.1.1'

答案 1 :(得分:0)

在res->值-> style.xml下打开style.xml并更改此行

style name =“ AppTheme” parent =“ Theme.AppCompat.Light.DarkActionBar”>

输入基准。在Theme.AppCompat.Light.DarkActionBar之前

style name =“ AppTheme” parent =“ Base.Theme.AppCompat.Light.DarkActionBar”>

希望问题会解决。