Android Studio - Coordinatorlayout, Appbarlayout and Floatingactionbutton

Asked

Viewed 304 times

2

I started creating a new application, changed the project theme and got the following error:

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.(Coordinatorlayout.java:178) at android.support.design.widget.Coordinatorlayout.(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:190) 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) 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:366) 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.MergingUpdateQue.execute(Mergingupdatequeue.java:320) at com.intellij.util.ui.update.MergingUpdateQue.execute(Mergingupdatequeue.java:310) at com.intellij.util.ui.update.Mergingupdatequeue$2.run(Mergingupdatequeue.java:254) at com.intellij.util.ui.update.MergingUpdateQue.flush(Mergingupdatequeue.java:269) at com.intellij.util.ui.update.MergingUpdateQue.flush(Mergingupdatequeue.java:227) at com.intellij.util.ui.update.MergingUpdateQue.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)

  • There is no need for the term in English.

2 answers

1

The error is self-explanatory

You need to use a Theme.Appcompat Theme (or Descendant) with the design library

If you are using the design library, you must obligatorily use the Theme Theme.AppCompat or some derivative thereof.

  • But then how should I proceed to use other themes? ?

  • @user36323 Or don’t use the design library or modify it to your specifications, create a new theme with Theme.Appcompat as the basis.

1

Uses Theme.Appcompat as the parent of your themes in Styles.xml

<style name="AppTheme" parent="Theme.AppCompat">
</style>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.