Status Update
Comments
ch...@gmail.com <ch...@gmail.com> #2
Problem:
It seems the Layout Editor has some troubles if you have to much attributes in one <declare-stylable> tag defined in your attr.xml!
Solution:
I have 49 attributes in one <declare-stylable> tag.
If I remove 5 attributes, so I have 45, the Layout Editor is working.
Reproduce:
Create in your attr.xml one <declare-stylable> tag and add more than 45 attributes to it.
It seems the Layout Editor has some troubles if you have to much attributes in one <declare-stylable> tag defined in your attr.xml!
Solution:
I have 49 attributes in one <declare-stylable> tag.
If I remove 5 attributes, so I have 45, the Layout Editor is working.
Reproduce:
Create in your attr.xml one <declare-stylable> tag and add more than 45 attributes to it.
uc...@google.com <uc...@google.com> #3
can you share a sample attr.xml file to reproduce this issue
ch...@gmail.com <ch...@gmail.com> #4
Yes of course. Attached is an attrs.xml with a <declare-styleable> tag named "Theme" with more than 45 entries!
uc...@google.com <uc...@google.com> #5
Not reproduced.
ch...@gmail.com <ch...@gmail.com> #6
You can't reproduce?
It is reproducable on my machine. I remove some of it and the problem is gone.
I add again a few that I am over 45 and I get again the error.
On Stack Overflow another user has reported this with ConstraintLayout.
After I am sent him the workaround his problem is also gone.
See this thread:
https://stackoverflow.com/questions/47692272/constraint-layout-render-problems-layout-editor/48140362#48140362
And my thread about Toolbar, it is the same problem and solution:
https://stackoverflow.com/questions/48119408/layout-edtior-not-showing-toolbar-negativearraysizeexception
It is reproducable on my machine. I remove some of it and the problem is gone.
I add again a few that I am over 45 and I get again the error.
On Stack Overflow another user has reported this with ConstraintLayout.
After I am sent him the workaround his problem is also gone.
See this thread:
And my thread about Toolbar, it is the same problem and solution:
Description
AI-171.4443003, JRE 1.8.0_152-release-915-b01x64 JetBrains s.r.o, OS Windows 10(amd64) v10.0 , screens 1920x1080, 1920x1080
XML Layout:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="
xmlns:app="
android:id="@+id/toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:theme="?attr/toolbarTheme"
app:popupTheme="?attr/toolbarPopupTheme"/>
If you opne it with Design or Preview you get:
The following classes could not be instantiated:
- android.support.v7.widget.Toolbar (Open Class, Show Exception, Clear Cache)
Preview Error Exception:
java.lang.NegativeArraySizeException
at android.support.v7.appcompat.R$styleable.<clinit>(Unknown Source)
at android.support.v7.widget.Toolbar.<init>(Toolbar.java:235)
at android.support.v7.widget.Toolbar.<init>(Toolbar.java:228)
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: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:211)
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:547)
at com.android.tools.idea.rendering.RenderTask.lambda$inflate$3(RenderTask.java:681)
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)
Gradle:
implementation "com.android.support:appcompat-v7:${supportLibVersion}"