xml - Android Studio: android.support.v7.widget.Toolbar can not be initiated -
i developing toolbar android app , after creating tool_bar.xml
file, ide showing error following classes can not initiated - android.support.v7.widget.toolbar
the full error details are
java.lang.noclassdeffounderror: android/support/v7/appcompat/r$attr @ android.support.v7.widget.toolbar.<init>(toolbar.java:191) @ sun.reflect.nativeconstructoraccessorimpl.newinstance0(native method) @ sun.reflect.nativeconstructoraccessorimpl.newinstance(nativeconstructoraccessorimpl.java:57) @ sun.reflect.delegatingconstructoraccessorimpl.newinstance(delegatingconstructoraccessorimpl.java:45) @ java.lang.reflect.constructor.newinstance(constructor.java:526) @ org.jetbrains.android.uipreview.viewloader.createnewinstance(viewloader.java:413) @ org.jetbrains.android.uipreview.viewloader.loadview(viewloader.java:105) @ com.android.tools.idea.rendering.layoutlibcallback.loadview(layoutlibcallback.java:177) @ android.view.bridgeinflater.loadcustomview(bridgeinflater.java:214) @ android.view.bridgeinflater.createviewfromtag(bridgeinflater.java:142) @ android.view.layoutinflater.inflate(layoutinflater.java:482) @ android.view.layoutinflater.inflate(layoutinflater.java:385) @ com.android.layoutlib.bridge.impl.rendersessionimpl.inflate(rendersessionimpl.java:413) @ com.android.layoutlib.bridge.bridge.createsession(bridge.java:321) @ com.android.ide.common.rendering.layoutlibrary.createsession(layoutlibrary.java:350) @ com.android.tools.idea.rendering.rendertask$2.compute(rendertask.java:497) @ com.android.tools.idea.rendering.rendertask$2.compute(rendertask.java:485) @ com.intellij.openapi.application.impl.applicationimpl.runreadaction(applicationimpl.java:894) @ com.android.tools.idea.rendering.rendertask.createrendersession(rendertask.java:485) @ com.android.tools.idea.rendering.rendertask.render(rendertask.java:590) @ com.intellij.android.designer.designsurface.androiddesignereditorpanel$6.run(androiddesignereditorpanel.java:480) @ com.intellij.util.ui.update.mergingupdatequeue.execute(mergingupdatequeue.java:320) @ com.intellij.util.ui.update.mergingupdatequeue.execute(mergingupdatequeue.java:310) @ com.intellij.util.ui.update.mergingupdatequeue$2.run(mergingupdatequeue.java:254) @ com.intellij.util.ui.update.mergingupdatequeue.flush(mergingupdatequeue.java:269) @ com.intellij.util.ui.update.mergingupdatequeue.flush(mergingupdatequeue.java:227) @ com.intellij.util.ui.update.mergingupdatequeue.run(mergingupdatequeue.java:217) @ com.intellij.util.concurrency.queueprocessor.runsafely(queueprocessor.java:238) @ com.intellij.util.alarm$request$1.run(alarm.java:351) @ java.util.concurrent.executors$runnableadapter.call(executors.java:471) @ java.util.concurrent.futuretask.run(futuretask.java:262) @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1145) @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:615) @ java.lang.thread.run(thread.java:745)
my tool_bar.xml
file is:
<?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.toolbar xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> </android.support.v7.widget.toolbar>
anyone has idea why happening? have tried invalidating cache , rebuilding , cleaning project, , failed. switch api version didn't worked out.
probably need set app theme inherit theme.appcompat theme.
edit: if have imported more support things add it:
compile ('com.android.support:recyclerview-v7:22.2.0') { exclude module: 'support-v7' } compile ('com.android.support:cardview-v7:22.2.0') { exclude module: 'support-v7' } compile 'com.android.support:appcompat-v7:22.2.0'
it prevent importing wrong version of support library other libs. check if support libs have same version.
Comments
Post a Comment