Android Studio Action Bar Rendering in preview - android

After I updated the gradle and Android Studio and build tools, I encountered this weird problem in Android Studio when I go to any xml file:
Rendering Problems The following classes could not be instantiated:
- com.android.internal.widget.ActionBarView
java.lang.NullPointerException
at android.content.res.BridgeResources.getLayout(BridgeResources.java:255)
at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
at com.android.internal.widget.ActionBarView.<init>(ActionBarView.java:212)
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:375)
at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:100)
at com.android.tools.idea.rendering.LayoutlibCallback.loadView(LayoutlibCallback.java:172)
at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:207)
at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:132)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:802)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:778)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:805)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:778)
at android.view.LayoutInflater.inflate(LayoutInflater.java:500)
at android.view.LayoutInflater.inflate(LayoutInflater.java:410)
at com.android.layoutlib.bridge.bars.ActionBarLayout.<init>(ActionBarLayout.java:96)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.createActionBar(RenderSessionImpl.java:1620)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:352)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:329)
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:332)
at com.android.tools.idea.rendering.RenderService$3.compute(RenderService.java:575)
at com.android.tools.idea.rendering.RenderService$3.compute(RenderService.java:564)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:932)
at com.android.tools.idea.rendering.RenderService.createRenderSession(RenderService.java:564)
at com.android.tools.idea.rendering.RenderService.render(RenderService.java:691)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.doRender(AndroidLayoutPreviewToolWindowManager.java:586)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.access$1900(AndroidLayoutPreviewToolWindowManager.java:80)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$6$1.run(AndroidLayoutPreviewToolWindowManager.java:528)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:178)
at com.intellij.openapi.progress.ProgressManager.executeProcessUnderProgress(ProgressManager.java:209)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:212)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:171)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$6.run(AndroidLayoutPreviewToolWindowManager.java:523)
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:327)
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)
The app runs fine on the phone with the correct layout. It is just that I could not preview it in the Android Studio.
I tried not using the support library v7 and target apk 11 above and it does not remove the error.

Finally I found a solution by myself.
First, I created a new project with Android Studio, then I added all the sources files and resource files by external operations(copy and paste).
Then I changed the gradle.build to this:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/YouTubeAndroidPlayerApi.jar')
// compile 'com.android.support:appcompat-v7:19.0.+'
compile 'com.google.android.gms:play-services:5.0.+'
}
This fixed the problem partially, however, the preview still says missing style for the layout, so I go to the design tab of the layout and manually chose a suitable one(such as Holo.Light). Now everything works fine.

In the preview screen just change the theme to Holo.Light and it worked for me. No need to change grandle.build file.

Related

AppCompatActivity is not working properly

I am developing an app which uses AppCompatActivity. I have been struggling since so many days solving this error but no luck and no reply for such an answer on StackOverflow. The gradle is built successfully without any error. But when the app is installed in the device, I get a force close error.
I am attaching my Android Monitor(logcat) content here. Please help me with this.
java.lang.NoSuchMethodError:
android.support.v4.view.ViewCompat.setOnApplyWindowInsetsListener(Landroid/view/View;Landroid/support/v4/view/OnApplyWindowInsetsListener;)V
at
android.support.design.internal.ScrimInsetsFrameLayout.<init>(ScrimInsetsFrameLayout.java:61)
at
android.support.design.widget.NavigationView.<init>(NavigationView.java:99)
at
android.support.design.widget.NavigationView.<init>(NavigationView.java:95)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method) at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
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:465)
at
org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:172)
at
org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:105)
at
com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.java:186)
at
android.view.BridgeInflater.loadCustomView(BridgeInflater.java:334)
at
android.view.BridgeInflater.loadCustomView(BridgeInflater.java:345)
at
android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:245)
at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at
android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:858)
at
android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:834) at
android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
here is my gradle file attached. Please have a look at it.
The answer to my question was given by #Piyush. The two dependencies were clashing I guess. so in short the answer to my issue will be if you are using
compile 'com.android.support:appcompat-v7:24.+'
etc.
then DO NOT USE
compile 'com.google.android:support-v4:r7'
along with it.
Change your app compat gradle as like below
compile 'com.android.support:appcompat-v7:23.4.0'
don't use gradle with +
compile 'com.android.support:appcompat-v7:23.+'
Hope this helps..!!

Android Studio layout not rendering [duplicate]

This question already has an answer here:
Rendering Problems Exception raised during rendering: com/android/util/PropertiesMap [duplicate]
(1 answer)
Closed 6 years ago.
I just installed updated AS 2.1.1. and created a new project with LogIn activity. I haven't touched anything yet. But when I went in resources/layout/activity_login the layout is not rendering. Before there used to be a small phone with layout rendered on it. Now it displays and error message. I tried creating other project with a different activity but the problem persists.
This is the error message
Rendering Problems
Exception raised during rendering: com/android/util/PropertiesMap
Details
java.lang.NoClassDefFoundError: com/android/util/PropertiesMap
at com.android.layoutlib.bridge.android.BridgeContext.createStyleBasedTypedArray(BridgeContext.java:940)
at com.android.layoutlib.bridge.android.BridgeContext.obtainStyledAttributes(BridgeContext.java:638)
at android.content.res.Resources_Theme_Delegate.obtainStyledAttributes(Resources_Theme_Delegate.java:71)
at android.content.res.Resources$Theme.obtainStyledAttributes(Resources.java:1436)
at android.widget.TextView.<init>(TextView.java:761)
at android.widget.TextView.<init>(TextView.java:704)
at android.widget.TextView.<init>(TextView.java:700)
at com.android.layoutlib.bridge.MockView.<init>(MockView.java:50)
at com.android.layoutlib.bridge.MockView.<init>(MockView.java:45)
at com.android.layoutlib.bridge.MockView.<init>(MockView.java:41)
at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:163)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:858)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:834)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at com.android.layoutlib.bridge.bars.CustomBar.<init>(CustomBar.java:95)
at com.android.layoutlib.bridge.bars.StatusBar.<init>(StatusBar.java:67)
at com.android.layoutlib.bridge.impl.Layout.createStatusBar(Layout.java:222)
at com.android.layoutlib.bridge.impl.Layout.<init>(Layout.java:144)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:297)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:429)
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:350)
at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:520)
at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:508)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:967)
at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:508)
at com.android.tools.idea.rendering.RenderTask.access$600(RenderTask.java:75)
at com.android.tools.idea.rendering.RenderTask$3.call(RenderTask.java:620)
at com.android.tools.idea.rendering.RenderTask$3.call(RenderTask.java:617)
at com.android.tools.idea.rendering.RenderService.runRenderAction(RenderService.java:371)
at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:617)
at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:639)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.doRender(AndroidLayoutPreviewToolWindowManager.java:654)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.access$1700(AndroidLayoutPreviewToolWindowManager.java:82)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7$1.run(AndroidLayoutPreviewToolWindowManager.java:596)
at com.intellij.openapi.progress.impl.CoreProgressManager$2.run(CoreProgressManager.java:142)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:446)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:392)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:54)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:127)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7.run(AndroidLayoutPreviewToolWindowManager.java:591)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:337)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:327)
at com.intellij.util.ui.update.MergingUpdateQueue$3.run(MergingUpdateQueue.java:271)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:286)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:244)
at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:234)
at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
at com.intellij.util.Alarm$Request$1.run(Alarm.java:352)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
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)
Try to change the render API to a lower one. (There's a little droid icon above your render view.)
Try to change your layout API level is Android 23 it's work for my side.

Rendering problems with Android Studio after getting Android N SDK [duplicate]

This question already has answers here:
XML Rendering errors Android preview N
(4 answers)
Closed 6 years ago.
I got the Android N SDK and ever since Android Studio has been having problems rendering Views from the design library. I have tried changing the Android version used to render the layouts to Marshmallow cause I read that N as issues but it keeps saying rendering problems.
Here is the full stack it is showing:
android.content.res.Resources$NotFoundException: Unable to find resource ID #0x1080029
at android.content.res.Resources.getResourceName(Resources.java:2235)
at android.content.res.Resources.loadDrawableForCookie(Resources.java:2602)
at android.content.res.Resources.loadDrawable(Resources.java:2540)
at android.content.res.Resources.getDrawable(Resources.java:806)
at android.content.Context.getDrawable(Context.java:458)
at android.support.v4.content.ContextCompatApi21.getDrawable(ContextCompatApi21.java:26)
at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:321)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:180)
at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:70)
at android.support.v7.widget.AppCompatImageHelper.loadFromAttributes(AppCompatImageHelper.java:39)
at android.support.v7.widget.AppCompatImageButton.<init>(AppCompatImageButton.java:65)
at android.support.design.widget.VisibilityAwareImageButton.<init>(VisibilityAwareImageButton.java:37)
at android.support.design.widget.FloatingActionButton.<init>(FloatingActionButton.java:109)
at android.support.design.widget.FloatingActionButton.<init>(FloatingActionButton.java:105)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:458)
at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:170)
at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:103)
at com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.java:168)
at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:247)
at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:171)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:835)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:811)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:394)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:223)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:426)
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:350)
at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:510)
at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:498)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:888)
at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:498)
at com.android.tools.idea.rendering.RenderTask.access$600(RenderTask.java:72)
at com.android.tools.idea.rendering.RenderTask$3.call(RenderTask.java:610)
at com.android.tools.idea.rendering.RenderTask$3.call(RenderTask.java:607)
at com.android.tools.idea.rendering.RenderService.runRenderAction(RenderService.java:362)
at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:607)
at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:629)
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:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
This is how it is rendering the layout when marshmallow is selected as the version to render layout:
Make sure that you downloaded Android N in the SDK Manager. You can find the SDK manager next to the purple phone/android (at the top menu bar).
And then, set targetto 24.

Rendering Problems every time I add a theme

I'm working on a new activity which I wanted to be blank by default. I then go into change the theme at activity_main.xml I changed it to "Black.NoTitleBar" which is the one I'm trying to work with. I get a rendering problem I look up the details seems like an easy fix just update. So I open up Android's SDK update tool. I download the recommended packages. Try the afforestation process again with the same result.
Notes:
I'm using 6.0 API 23
Packages listed as installed in my SDK manager: SDK Platform, ARM EABI v7a System Image, and Google API
I haven't touched any java files everything is default and lists no error.
Here are the exception details:
I saw a thread here with the same issue however their solution didn't work for me.
Exception Details
java.lang.IllegalArgumentException: You need to use a Theme.AppCompat theme (or descendant) with the design library.
at android.support.design.widget.ThemeUtils.checkAppCompatTheme(ThemeUtils.java:34)
at android.support.design.widget.CoordinatorLayout.<init>(CoordinatorLayout.java:178)
at android.support.design.widget.CoordinatorLayout.<init>(CoordinatorLayout.java:172)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:458)
at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:170)
at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:103)
at com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.java:168)
at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:247)
at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:171)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
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:223)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:426)
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:350)
at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:510)
at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:498)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:888)
at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:498)
at com.android.tools.idea.rendering.RenderTask.access$600(RenderTask.java:72)
at com.android.tools.idea.rendering.RenderTask$3.call(RenderTask.java:610)
at com.android.tools.idea.rendering.RenderTask$3.call(RenderTask.java:607)
at com.android.tools.idea.rendering.RenderService.runRenderAction(RenderService.java:362)
at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:607)
at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:629)
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:511)
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)
How can I fix this?
You need to use AppCompat themes, since you are using Android's Support Libraries. This is evident by the very first line of the exception.
If you do not need an action bar, you can use AppCompat.Light.NoActionBar as your theme.

Already disposedjava.lang.AssertionError when switching to design view in Android Studio

I get the following error when switching to Design View in Android Studio, nothing changed in the activity and it used to work before:
java.lang.AssertionError: Already disposed
at com.intellij.openapi.components.impl.ComponentManagerImpl.getPicoContainer(ComponentManagerImpl.java:263)
at com.intellij.openapi.components.impl.ComponentManagerImpl.getPicoContainer(ComponentManagerImpl.java:55)
at com.intellij.openapi.components.ServiceManager.getService(ServiceManager.java:40)
at com.intellij.openapi.roots.impl.DirectoryIndex.getInstance(DirectoryIndex.java:31)
at org.jetbrains.android.dom.AndroidXmlExtension.isAvailable(AndroidXmlExtension.java:52)
at com.intellij.xml.XmlExtension.getExtension(XmlExtension.java:48)
at com.intellij.xml.XmlExtension.getExtensionByElement(XmlExtension.java:59)
at com.intellij.psi.impl.source.xml.XmlTagImpl.computeNamespaceMap(XmlTagImpl.java:893)
at com.intellij.psi.impl.source.xml.XmlTagImpl.initNamespaceMaps(XmlTagImpl.java:857)
at com.intellij.psi.impl.source.xml.XmlTagImpl.getAttributeValue(XmlTagImpl.java:631)
at com.android.tools.idea.rendering.PsiResourceItem$1.getDefaultIndex(PsiResourceItem.java:160)
at com.android.ide.common.rendering.api.ArrayResourceValue.getValue(ArrayResourceValue.java:95)
at com.android.ide.common.resources.ResourceResolver.resolveResValue(ResourceResolver.java:272)
at com.android.ide.common.resources.ResourceResolver.resolveResValue(ResourceResolver.java:263)
at com.android.ide.common.resources.ResourceResolver.resolveValue(ResourceResolver.java:258)
at com.android.layoutlib.bridge.android.BridgeContext.obtainStyledAttributes(BridgeContext.java:705)
at android.widget.AbsSpinner.<init>(AbsSpinner.java:71)
at android.widget.Spinner.<init>(Spinner.java:165)
at android.widget.Spinner.<init>(Spinner.java:144)
at android.widget.Spinner.<init>(Spinner.java:128)
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 android.view.LayoutInflater.createView(LayoutInflater.java:594)
at android.view.BridgeInflater.onCreateView(BridgeInflater.java:86)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:131)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:755)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:758)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:758)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:373)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:399)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:336)
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:332)
at com.android.tools.idea.rendering.RenderService$3.compute(RenderService.java:542)
at com.android.tools.idea.rendering.RenderService$3.compute(RenderService.java:535)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:934)
at com.android.tools.idea.rendering.RenderService.createRenderSession(RenderService.java:535)
at com.android.tools.idea.rendering.RenderService.render(RenderService.java:577)
at com.intellij.android.designer.designSurface.AndroidDesignerEditorPanel$7$2.compute(AndroidDesignerEditorPanel.java:501)
at com.intellij.android.designer.designSurface.AndroidDesignerEditorPanel$7$2.compute(AndroidDesignerEditorPanel.java:494)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:945)
at com.intellij.android.designer.designSurface.AndroidDesignerEditorPanel$7.run(AndroidDesignerEditorPanel.java:494)
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:297)
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)
Any clues on this ?
Try to select File -> Invalidate Caches / Restart
I had a similar issue with Android Studio, and found this blog where the solution is posted.
I've posted this answer hoping it'll help other people who will search for this error.
My Android Studio version is 0.6.1 Preview version
UPDATE:
In IntelliJ 2021.3 a new feature, named Repair IDE, has been introduced which can be invoked from File -> Repair IDE or by searching for this action via Cmd + Shift + A (Mac) or Ctrl + Shift + A (Windows). Android Studio Dolphin, built on IntelliJ 2021.3, is the first to have this feature.

Categories

Resources