I have the following error in my preview window in the latest version of Android Studio (1.2) that stops me from being able to view the layout I am creating, I have tried restarting android studio several times as well as cleaning, rebuilding the project and restarting my computer
我在Android Studio(1.2)的最新版本的预览窗口中出现以下错误,导致我无法查看我正在创建的布局,我已尝试多次重启android studio以及清理,重建项目和重新启动我的电脑
EDIT:
Some projects have the same error while other older projects work fine
有些项目有相同的错误,而其他旧项目工作正常
The following classes could not be instantiated:
- android.support.v7.internal.widget.ActionBarOverlayLayout (Open Class, Show Exception, Clear Cache)
Exception Details
java.lang.NoClassDefFoundError: android/support/v7/internal/widget/ActionBarOverlayLayout$1
at android.support.v7.internal.widget.ActionBarOverlayLayout.<init>(ActionBarOverlayLayout.java:93)
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.inflate(LayoutInflater.java:482)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at com.android.layoutlib.bridge.bars.BridgeActionBar.<init>(BridgeActionBar.java:84)
at com.android.layoutlib.bridge.bars.AppCompatActionBar.<init>(AppCompatActionBar.java:56)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.createActionBar(RenderSessionImpl.java:1691)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:362)
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 org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.doRender(AndroidLayoutPreviewToolWindowManager.java:644)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.access$1700(AndroidLayoutPreviewToolWindowManager.java:79)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7$1.run(AndroidLayoutPreviewToolWindowManager.java:586)
at com.intellij.openapi.progress.impl.CoreProgressManager$2.run(CoreProgressManager.java:152)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:452)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:402)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:54)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:137)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7.run(AndroidLayoutPreviewToolWindowManager.java:581)
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)
3 个解决方案
#1
Try changing your base application theme using below code - in res/values/styles.xml
尝试使用下面的代码更改基本应用程序主题 - 在res / values / styles.xml中
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
OR
Also you can try Switching the preview's API level to lower one from the preview configuration
您也可以尝试将预览的API级别切换为预览配置中的较低级别
#2
You can also update Gradle to version 1.2.3 as explained here: https://code.google.com/p/android/issues/detail?id=171417
您还可以按照此处的说明将Gradle更新为1.2.3版:https://code.google.com/p/android/issues/detail?id = 171417
Apparently this was a bug on version 1.2.2 of Gradle and from the next version of Android studio Gradle 1.2.3 will be the default on new projects.
显然,这是Gradle版本1.2.2的一个错误,从下一个版本的Android Studio Gradle 1.2.3将是新项目的默认设置。
At least it worked for.
至少它起作用了。
While Base.Theme.AppCompat.... is the superclass of Theme.AppCompat.... anyway, I prefer the fix using the new version of Gradle.
虽然Base.Theme.AppCompat ....是Theme.AppCompat的超类....无论如何,我更喜欢使用新版Gradle的修复。
Worked for me, hope it works for you.
为我工作,希望它适合你。
Also I had to Clean and Rebuild the Project.
我还必须清理并重建项目。
#3
The easiest way would be to change the theme of the application by clicking AppTheme.
最简单的方法是通过单击AppTheme来更改应用程序的主题。
This does not need to change anything in the code.
这不需要在代码中更改任何内容。
I attach the image below
我附上下面的图片
AppTheme example of solution render problem android studio
AppTheme解决方案渲染问题android studio的例子
#1
Try changing your base application theme using below code - in res/values/styles.xml
尝试使用下面的代码更改基本应用程序主题 - 在res / values / styles.xml中
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
OR
Also you can try Switching the preview's API level to lower one from the preview configuration
您也可以尝试将预览的API级别切换为预览配置中的较低级别
#2
You can also update Gradle to version 1.2.3 as explained here: https://code.google.com/p/android/issues/detail?id=171417
您还可以按照此处的说明将Gradle更新为1.2.3版:https://code.google.com/p/android/issues/detail?id = 171417
Apparently this was a bug on version 1.2.2 of Gradle and from the next version of Android studio Gradle 1.2.3 will be the default on new projects.
显然,这是Gradle版本1.2.2的一个错误,从下一个版本的Android Studio Gradle 1.2.3将是新项目的默认设置。
At least it worked for.
至少它起作用了。
While Base.Theme.AppCompat.... is the superclass of Theme.AppCompat.... anyway, I prefer the fix using the new version of Gradle.
虽然Base.Theme.AppCompat ....是Theme.AppCompat的超类....无论如何,我更喜欢使用新版Gradle的修复。
Worked for me, hope it works for you.
为我工作,希望它适合你。
Also I had to Clean and Rebuild the Project.
我还必须清理并重建项目。
#3
The easiest way would be to change the theme of the application by clicking AppTheme.
最简单的方法是通过单击AppTheme来更改应用程序的主题。
This does not need to change anything in the code.
这不需要在代码中更改任何内容。
I attach the image below
我附上下面的图片
AppTheme example of solution render problem android studio
AppTheme解决方案渲染问题android studio的例子