简体   繁体   English

无法实例化以下类:android.support.design.widget.CoordinatorLayout

[英]The following classes could not be instantiated: android.support.design.widget.CoordinatorLayout

Anybody know what this is about?有人知道这是关于什么的吗?

Here are my dependencies:这是我的依赖项:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:design:22.2.0'
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.android.support:cardview-v7:22.0.0'
    compile 'com.android.support:gridlayout-v7:22.0.0'
    compile 'com.android.support:palette-v7:22.0.0'
    compile 'com.android.support:recyclerview-v7:22.0.0'
}

I imported everything from the Android Support Library and synced the Gradles.我从 Android 支持库中导入了所有内容并同步了 Gradle。 Anybody know why I am getting rendering problems in the layout?有人知道为什么我在布局中遇到渲染问题吗?

Here is the error log:这是错误日志:


java.lang.NoClassDefFoundError: Could not initialize class android.support.design.widget.CoordinatorLayout
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:413)
    at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:105)
    at com.android.tools.idea.rendering.LayoutlibCallback.loadView(LayoutlibCallback.java:177)
    at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:214)
    at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:142)
    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)
    at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:413)
    at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:321)
    at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:350)
    at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:497)
    at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:485)
    at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:894)
    at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:485)
    at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:590)
    at com.intellij.android.designer.designSurface.AndroidDesignerEditorPanel$6.run(AndroidDesignerEditorPanel.java:480)
    at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320)
    at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310)
    at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.java:254)
    at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269)
    at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227)
    at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217)
    at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
    at com.intellij.util.Alarm$Request$1.run(Alarm.java:351)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:695)

Am also faced same problem as per your scenario after import the support libraries and synced the Gradles need to rebuild your project .在导入支持库并同步 Gradles 需要重建您的项目后,我也面临与您的场景相同的问题。

After i have done this procedure its working for me, i hope this will helpful.在我完成此程序后,它对我有用,我希望这会有所帮助。

The following classes could not be instantiated: android.support.design.widget.CoordinatorLayout无法实例化以下类:android.support.design.widget.CoordinatorLayout

This is simply because android.support.design.widget.CoordinatorLayout is added in version 24.1.0 .这仅仅是因为android.support.design.widget.CoordinatorLayout在 24.1.0 版本中添加的 So, the support library dependency is incorrect.所以,支持库依赖是不正确的。 The dependencies should be updated at least to version 24.1.0 or using the latest support libraries (28.0.0).依赖项至少应更新到版本24.1.0或使用最新的支持库 (28.0.0)。 Something like this:像这样的东西:

dependencies {

    compile 'com.android.support:design:28.0.0'
    compile 'com.android.support:appcompat-v7:28.0.0'
    compile 'com.android.support:cardview-v7:28.0.0'
    compile 'com.android.support:gridlayout-v7:28.0.0'
    compile 'com.android.support:palette-v7:28.0.0'
    compile 'com.android.support:recyclerview-v7:28.0.0'
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 以下类无法实例化android.support.design.widget.CoordinatorLayout - The following classes could not be instantiated android.support.design.widget.CoordinatorLayout 呈现问题以下类无法实例化: - android.support.design.widget.CoordinatorLayout - Rendering Problems The following classes could not be instantiated: - android.support.design.widget.CoordinatorLayout 无法初始化类android.support.design.widget.CoordinatorLayout - Could not initialize class android.support.design.widget.CoordinatorLayout 未声明android.support.design.widget.CoordinatorLayout - The android.support.design.widget.CoordinatorLayout is not declared android.support.design.widget.CoordinatorLayout 错误 - android.support.design.widget.CoordinatorLayout error 无法实例化以下类:-android.support.design.widget.BottomNavigationView - The following classes could not be instantiated: - android.support.design.widget.BottomNavigationView 以下类无法实例化:-android.support.design.widget.FloatingActionButton - The following classes could not be instantiated: - android.support.design.widget.FloatingActionButton 无法实例化以下类:-android.support.design.widget.TextInputLayout - The following classes could not be instantiated: - android.support.design.widget.TextInputLayout 无法实例化以下类,android.support.design.widget.FloatingActionButton - The following classes could not be instantiated,android.support.design.widget.FloatingActionButton 以下类无法实例化android.support.design.widget.floatingactionbutton - the following classes could not be instantiated android.support.design.widget.floatingactionbutton
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM