multiline-collapsingtoolbar icon indicating copy to clipboard operation
multiline-collapsingtoolbar copied to clipboard

Rendering problem with Android Studio in preview

Open PureDark opened this issue 7 years ago • 2 comments

 Rendering Problems The following classes could not be instantiated: - net.opacapp.multilinecollapsingtoolbar.CollapsingToolbarLayout (Open Class, Show Exception, Clear Cache) Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE.
If this is an unexpected error you can also try to build the project, then manually refresh the layout.
Exception Details android.content.res.Resources$NotFoundException at com.android.layoutlib.bridge.android.BridgeContext.obtainStyledAttributes(BridgeContext.java:656) 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.content.Context.obtainStyledAttributes(Context.java:587) at net.opacapp.multilinecollapsingtoolbar.CollapsingTextHelper.setExpandedTextAppearance(CollapsingTextHelper.java:241) at net.opacapp.multilinecollapsingtoolbar.CollapsingToolbarLayout.(CollapsingToolbarLayout.java:185) at net.opacapp.multilinecollapsingtoolbar.CollapsingToolbarLayout.(CollapsingToolbarLayout.java:136) 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.rInflate_Original(LayoutInflater.java:861) 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) at android.view.LayoutInflater.inflate(LayoutInflater.java:397) at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:324) at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:429) at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:389) at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:548) at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:533) at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:966) at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:533) at com.android.tools.idea.rendering.RenderTask.lambda$inflate$72(RenderTask.java:659) 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)

PureDark avatar Aug 11 '16 17:08 PureDark

Indeed, that error is also occurring on Android Studio 2.1 (stable) for me.

I'm currently not sure what's causing this, but I'll try to look into it soon. If anyone else has an idea, feel free to write here or send a Pull Request.

johan12345 avatar Aug 13 '16 10:08 johan12345

As far as I understand, this seems to be caused by resources from the appcompat support library that are marked as private, such as

android.support.v7.appcompat.R.styleable.TextAppearance_android_textColor

These are not found by the layout preview for some reason.

If this is the reason, I see no way to fix it other than copying all the resources to our library and replacing them, which potentially increases the effort needed to maintain this library even more.

johan12345 avatar Oct 19 '16 20:10 johan12345