J'ai un problème avec la prévisualisation dans Android Studio lorsque j'utilise la bibliothèque de support. 26.0.0-beta2
Si j'utilise des widgets AppCompat dans ma mise en page, ils ne s'affichent pas dans l'aperçu.
tout fonctionne bien lorsque l'on utilise 26.0.0-beta1
.
Le texte d'erreur dans la fenêtre d'aperçu ressemble à ceci :
The following classes could not be instantiated:
- android.support.v7.widget.AppCompatImageView (Open Class, Show Exception, Clear Cache)
- android.support.v7.widget.RecyclerView (Open Class, Show Exception, Clear Cache)
- android.support.v7.widget.AppCompatRadioButton (Open Class, Show Exception, Clear Cache)
- android.support.constraint.ConstraintLayout (Open Class, Show Exception, Clear Cache)
- android.support.v7.widget.AppCompatTextView (Open Class, Show Exception, Clear Cache)
J'utilise Android studio 3 canary 5 (le problème était aussi dans canary 4). kotlin 1.1.3
runtime et plugin. gradle 3.0.0-alpha5
wrapper gradle gradle-4.1-milestone-1-all.zip
thème de prévisualisation Theme.AppCompat.Light.NoActionBar
exception affichée dans la fenêtre de visualisation :
java.lang.AssertionError: Entries for a declare-styleable should be after the array declaration.
at com.android.tools.idea.res.AppResourceRepository.getDeclaredArrayValues(AppResourceRepository.java:634)
at com.android.tools.idea.res.ResourceClassGenerator.generateStyleable(ResourceClassGenerator.java:249)
at com.android.tools.idea.res.ResourceClassGenerator.generate(ResourceClassGenerator.java:120)
at com.android.tools.idea.res.ResourceClassRegistry.findClassDefinition(ResourceClassRegistry.java:102)
at org.jetbrains.android.uipreview.ModuleClassLoader.findClass(ModuleClassLoader.java:101)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.jetbrains.android.uipreview.ModuleClassLoader.loadClass(ModuleClassLoader.java:215)
at android.support.v7.widget.AppCompatBackgroundHelper.loadFromAttributes(AppCompatBackgroundHelper.java:46)
at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:73)
at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:66)
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.loadClass(ViewLoader.java:215)
at com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadClass(LayoutlibCallbackImpl.java:214)
at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:336)
at android.view.BridgeInflater.onCreateView(BridgeInflater.java:155)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:720)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:788)
at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:225)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:863)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:837)
at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
at com.android.layoutlib.bridge.bars.CustomBar.<init>(CustomBar.java:90)
at com.android.layoutlib.bridge.bars.NavigationBar.<init>(NavigationBar.java:52)
at com.android.layoutlib.bridge.bars.NavigationBar.<init>(NavigationBar.java:46)
at com.android.layoutlib.bridge.impl.Layout.createNavBar(Layout.java:325)
at com.android.layoutlib.bridge.impl.Layout.<init>(Layout.java:151)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:297)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:382)
at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:193)
at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:591)
at com.android.tools.idea.rendering.RenderTask.lambda$inflate$3(RenderTask.java:739)
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)