有人知道这是关于什么的吗?
以下是我的依赖项:
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'
}
我从Android支持库导入了所有内容并同步了Gradles。有谁知道为什么我在布局中出现渲染问题?
以下是错误日志:
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)
答案 0 :(得分:0)
在导入支持库并同步Gradles需要重建项目后,我的方案也面临同样的问题。
在我完成这个程序后,它为我工作,我希望这会有所帮助。
答案 1 :(得分:0)
无法实例化以下类:android.support.design.widget.CoordinatorLayout
这仅仅是因为android.support.design.widget.CoordinatorLayout
是added in version 24.1.0。因此,支持库依赖关系不正确。依赖性至少应更新为版本24.1.0
或使用最新的支持库(28.0.0)。像这样:
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'
}