android.support.v4.widget.DrawerLayout无法实例化-实现的损坏类路径

时间:2019-01-22 09:59:17

标签: java android intellij-idea android-gradle build.gradle

我正在创建导航抽屉,而我的项目无法实例化DrawerLayout类。我该如何解决?

我正在创建一个应用程序,并且希望有一个来自屏幕侧面的导航。 当我尝试输入DrawerLayout时,遇到了渲染问题和样式丢失。 我的主题是“ Theme.AppCompat.Light.DarkActionBar.NoActionBar”。 在线发布的答案都没有帮助我... 我在以下帖子中进行了搜索:
Rendering problems, could not find android.support.v4.widget.Drawerlayout
java android.support.v4.widget.DrawerLayout not being found
Rendering Problems: Class could not be instantiated: - android.support.v4.widget.DrawerLayout
Android: Navigation Drawer activity - "The following classes could not be instantiated:"
android.support.v4.widget.Drawerlayout could not be instantiated
android.support.v4.widget.DrawerLayout Cannot be instantiated

当我查看项目结构内部时,发现了30个问题,我认为是什么原因造成的。

The '30 Problems':
1. Library Gradle: android.arch.core:runtime-1.1.1 has broken classes path:   C:\Users\ys571\.gradle\caches\transforms-1\files-1.1\runtime-1.1.1.aar\1ed9abb76df57a728e56a0d377980a42\res [Fix]
2. Library Gradle: android.arch.lifecycle:livedata-1.1.1 has broken classes path:   C:\Users\ys571\.gradle\caches\transforms-1\files-1.1\livedata-1.1.1.aar\bb114928e69dc70ac669dbbb75092cb3\res [Fix]
3. Library Gradle: android.arch.lifecycle:livedata-core-1.1.1 has broken classes path:   C:\Users\ys571\.gradle\caches\transforms-1\files-1.1\livedata-core-1.1.1.aar\8ff3e0bbe6d32a4fe667e4f0b7dbcdc6\res [Fix]
4. Library Gradle: android.arch.lifecycle:runtime-1.1.1 has broken classes path:   C:\Users\ys571\.gradle\caches\transforms-1\files-1.1\runtime-1.1.1.aar\77ed501e72ab2e9c8657211a431aef75\res [Fix]
5. Library Gradle: android.arch.lifecycle:viewmodel-1.1.1 has broken classes path:   C:\Users\ys571\.gradle\caches\transforms-1\files-1.1\viewmodel-1.1.1.aar\de829b9d223f4f8f74006d0d62f94188\res [Fix]
6. Library Gradle: com.android.support.test.espresso:espresso-core-3.0.2 has broken classes path:   C:\Users\ys571\.gradle\caches\transforms-1\files-1.1\espresso-core-3.0.2.aar\f18942ca7086b3fed7fbe1ab6bdf2f82\res [Fix]
7. Library Gradle: com.android.support.test.espresso:espresso-idling-resource-3.0.2 has broken classes path:   C:\Users\ys571\.gradle\caches\transforms-1\files-1.1\espresso-idling-resource-3.0.2.aar\28e9ae2f90ceee2efcdc553851d9c2ec\res [Fix]
8. Library Gradle: com.android.support.test:monitor-1.0.2 has broken classes path:   C:\Users\ys571\.gradle\caches\transforms-1\files-1.1\monitor-1.0.2.aar\42df670f042897b728f01ee50faa0bbe\res [Fix]
9. Library Gradle: com.android.support.test:runner-1.0.2 has broken classes path:   C:\Users\ys571\.gradle\caches\transforms-1\files-1.1\runner-1.0.2.aar\bf542da1f75fcb465f7a87191d034c57\res [Fix]
10. Library Gradle: com.android.support:animated-vector-drawable-28.0.0 has broken classes path:   C:\Users\ys571\.gradle\caches\transforms-1\files-1.1\animated-vector-drawable-28.0.0.aar\682838ee28152ff81a88adc290532743\res [Fix]
11. Library Gradle: com.android.support:asynclayoutinflater-28.0.0 has broken classes path:   C:\Users\ys571\.gradle\caches\transforms-1\files-1.1\asynclayoutinflater-28.0.0.aar\daf27663d33e8ad47792184a939b46de\res [Fix]
12. Library Gradle: com.android.support:cursoradapter-28.0.0 has broken classes path:   C:\Users\ys571\.gradle\caches\transforms-1\files-1.1\cursoradapter-28.0.0.aar\4cc8400b5bc0090a45f9b5aa86913a67\res [Fix]
13. Library Gradle: com.android.support:customview-28.0.0 has broken classes path:   C:\Users\ys571\.gradle\caches\transforms-1\files-1.1\customview-28.0.0.aar\c1b96ade1c1f810680f95fed2dd38150\res [Fix]
14. Library Gradle: com.android.support:documentfile-28.0.0 has broken classes path:   C:\Users\ys571\.gradle\caches\transforms-1\files-1.1\documentfile-28.0.0.aar\101102579587b4c97690c3906a9fbc45\res [Fix]
15. Library Gradle: com.android.support:drawerlayout-28.0.0 has broken classes path:   C:\Users\ys571\.gradle\caches\transforms-1\files-1.1\drawerlayout-28.0.0.aar\887e59c896b92e48cd63d660a3ad0d2b\res [Fix]
16. Library Gradle: com.android.support:interpolator-28.0.0 has broken classes path:   C:\Users\ys571\.gradle\caches\transforms-1\files-1.1\interpolator-28.0.0.aar\3d7173e69a76d2ab6de6f99ed609f170\res [Fix]
17. Library Gradle: com.android.support:loader-28.0.0 has broken classes path:   C:\Users\ys571\.gradle\caches\transforms-1\files-1.1\loader-28.0.0.aar\011b279f73f14d976da4fefa2c049945\res [Fix]
18. Library Gradle: com.android.support:localbroadcastmanager-28.0.0 has broken classes path:   C:\Users\ys571\.gradle\caches\transforms-1\files-1.1\localbroadcastmanager-28.0.0.aar\274feffa4a7039599e2c8d2beda26909\res [Fix]
19. Library Gradle: com.android.support:print-28.0.0 has broken classes path:   C:\Users\ys571\.gradle\caches\transforms-1\files-1.1\print-28.0.0.aar\b39a51f640b52355ef1e0b5faf7ffd8e\res [Fix]
20. Library Gradle: com.android.support:slidingpanelayout-28.0.0 has broken classes path:   C:\Users\ys571\.gradle\caches\transforms-1\files-1.1\slidingpanelayout-28.0.0.aar\9bd00f1e7dd4a51a03b2b92185c7e486\res [Fix]
21. Library Gradle: com.android.support:support-core-ui-28.0.0 has broken classes path:   C:\Users\ys571\.gradle\caches\transforms-1\files-1.1\support-core-ui-28.0.0.aar\e6a91ff213a21cd983a7fb6bd4c2e053\res [Fix]
22. Library Gradle: com.android.support:support-core-utils-28.0.0 has broken classes path:   C:\Users\ys571\.gradle\caches\transforms-1\files-1.1\support-core-utils-28.0.0.aar\ee00eb82fa1334c7d0b8318162ec09b7\res [Fix]
23. Library Gradle: com.android.support:support-fragment-28.0.0 has broken classes path:   C:\Users\ys571\.gradle\caches\transforms-1\files-1.1\support-fragment-28.0.0.aar\554530d0b22d35d050ce20c30641a9c9\res [Fix]
24. Library Gradle: com.android.support:support-v4-28.0.0 has broken classes path:   C:\Users\ys571\.gradle\caches\transforms-1\files-1.1\support-v4-28.0.0.aar\c4e4a038d28d012e80847b5e3950e75f\res [Fix]
25. Library Gradle: com.android.support:support-vector-drawable-28.0.0 has broken classes path:   C:\Users\ys571\.gradle\caches\transforms-1\files-1.1\support-vector-drawable-28.0.0.aar\9586bcb98270a789084fec5886c2b31b\res [Fix]
26. Library Gradle: com.android.support:swiperefreshlayout-28.0.0 has broken classes path:   C:\Users\ys571\.gradle\caches\transforms-1\files-1.1\swiperefreshlayout-28.0.0.aar\f606599c716f9a4c2ac21f4fbd220878\res [Fix]
27. Library Gradle: com.android.support:versionedparcelable-28.0.0 has broken classes path:   C:\Users\ys571\.gradle\caches\transforms-1\files-1.1\versionedparcelable-28.0.0.aar\2cb1929b825c084558dea2e1f7325933\res [Fix]
28. Library Gradle: com.android.support:viewpager-28.0.0 has broken classes path:   C:\Users\ys571\.gradle\caches\transforms-1\files-1.1\viewpager-28.0.0.aar\eccad61e3466954426c6e599ee6846a4\res [Fix]
29. Library Gradle: com.google.android.gms:play-services-places-placereport-16.0.0 has broken classes path:   C:\Users\ys571\.gradle\caches\transforms-1\files-1.1\play-services-places-placereport-16.0.0.aar\18c1ae959910956c0d3900a36cdf21c9\res [Fix]
30. Library Gradle: com.google.android.gms:play-services-tasks-16.0.1 has broken classes path:   C:\Users\ys571\.gradle\caches\transforms-1\files-1.1\play-services-tasks-16.0.1.aar\3bab695efab919e8714ee099972c1110\res [Fix] 

我从DrawerLayout中收到的异常是:

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.v4.widget.DrawerLayout.<init>(DrawerLayout.java:336)
at android.support.v4.widget.DrawerLayout.<init>(DrawerLayout.java:310)
at sun.reflect.GeneratedConstructorAccessor3668.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:481)
at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:264)
at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:222)
at com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.java:209)
at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:337)
at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:348)
at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:248)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:394)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:325)
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)

我希望实现的依赖项不会有我认为引起异常的类路径中断。

0 个答案:

没有答案