java - Error inflating class android.support.v7.internal.widget.NativeActionModeAwareLayout -
someone please me if solved problem before.
i trying make material design app can run low api 10. have no error in code whatsoever keep getting error.
android logcat
06-01 05:05:37.414: e/androidruntime(7043): fatal exception: main 06-01 05:05:37.414: e/androidruntime(7043): java.lang.runtimeexception: unable start activity componentinfo{com.chano8.app/com.chano8.app.mainactivity}: android.view.inflateexception: binary xml file line #19: error inflating class android.support.v7.internal.widget.nativeactionmodeawarelayout 06-01 05:05:37.414: e/androidruntime(7043): @ android.app.activitythread.performlaunchactivity(activitythread.java:2351) 06-01 05:05:37.414: e/androidruntime(7043): @ android.app.activitythread.handlelaunchactivity(activitythread.java:2403) 06-01 05:05:37.414: e/androidruntime(7043): @ android.app.activitythread.access$600(activitythread.java:165) 06-01 05:05:37.414: e/androidruntime(7043): @ android.app.activitythread$h.handlemessage(activitythread.java:1373) 06-01 05:05:37.414: e/androidruntime(7043): @ android.os.handler.dispatchmessage(handler.java:107) 06-01 05:05:37.414: e/androidruntime(7043): @ android.os.looper.loop(looper.java:194) 06-01 05:05:37.414: e/androidruntime(7043): @ android.app.activitythread.main(activitythread.java:5370) 06-01 05:05:37.414: e/androidruntime(7043): @ java.lang.reflect.method.invokenative(native method) 06-01 05:05:37.414: e/androidruntime(7043): @ java.lang.reflect.method.invoke(method.java:525) 06-01 05:05:37.414: e/androidruntime(7043): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:833) 06-01 05:05:37.414: e/androidruntime(7043): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:600) 06-01 05:05:37.414: e/androidruntime(7043): @ dalvik.system.nativestart.main(native method) 06-01 05:05:37.414: e/androidruntime(7043): caused by: android.view.inflateexception: binary xml file line #19: error inflating class android.support.v7.internal.widget.nativeactionmodeawarelayout 06-01 05:05:37.414: e/androidruntime(7043): @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:698) 06-01 05:05:37.414: e/androidruntime(7043): @ android.view.layoutinflater.rinflate(layoutinflater.java:746) 06-01 05:05:37.414: e/androidruntime(7043): @ android.view.layoutinflater.parseinclude(layoutinflater.java:805) 06-01 05:05:37.414: e/androidruntime(7043): @ android.view.layoutinflater.rinflate(layoutinflater.java:736) 06-01 05:05:37.414: e/androidruntime(7043): @ android.view.layoutinflater.inflate(layoutinflater.java:489) 06-01 05:05:37.414: e/androidruntime(7043): @ android.view.layoutinflater.inflate(layoutinflater.java:396) 06-01 05:05:37.414: e/androidruntime(7043): @ android.view.layoutinflater.inflate(layoutinflater.java:352) 06-01 05:05:37.414: e/androidruntime(7043): @ android.support.v7.app.appcompatdelegateimplv7.ensuresubdecor(appcompatdelegateimplv7.java:324) 06-01 05:05:37.414: e/androidruntime(7043): @ android.support.v7.app.appcompatdelegateimplv7.setcontentview(appcompatdelegateimplv7.java:246) 06-01 05:05:37.414: e/androidruntime(7043): @ android.support.v7.app.appcompatactivity.setcontentview(appcompatactivity.java:106) 06-01 05:05:37.414: e/androidruntime(7043): @ com.chano8.app.mainactivity.oncreate(mainactivity.java:33) 06-01 05:05:37.414: e/androidruntime(7043): @ android.app.activity.performcreate(activity.java:5228) 06-01 05:05:37.414: e/androidruntime(7043): @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1150) 06-01 05:05:37.414: e/androidruntime(7043): @ android.app.activitythread.performlaunchactivity(activitythread.java:2315) 06-01 05:05:37.414: e/androidruntime(7043): ... 11 more 06-01 05:05:37.414: e/androidruntime(7043): caused by: java.lang.classnotfoundexception: didn't find class "android.support.v7.internal.widget.nativeactionmodeawarelayout" on path: dexpathlist[[zip file "/data/app/com.chano8.app-1.apk"],nativelibrarydirectories=[/data/app-lib/com.chano8.app-1, /vendor/lib, /system/lib]] 06-01 05:05:37.414: e/androidruntime(7043): @ dalvik.system.basedexclassloader.findclass(basedexclassloader.java:53) 06-01 05:05:37.414: e/androidruntime(7043): @ java.lang.classloader.loadclass(classloader.java:501) 06-01 05:05:37.414: e/androidruntime(7043): @ java.lang.classloader.loadclass(classloader.java:461) 06-01 05:05:37.414: e/androidruntime(7043): @ android.view.layoutinflater.createview(layoutinflater.java:552) 06-01 05:05:37.414: e/androidruntime(7043): @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:687) 06-01 05:05:37.414: e/androidruntime(7043): ... 24 more
below code crashing according above logcat. mainactivity.java
private static string tag = mainactivity.class.getsimplename(); private toolbar mtoolbar; private fragmentdrawer drawerfragment; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); mtoolbar = (toolbar) findviewbyid(r.id.toolbar); setsupportactionbar(mtoolbar); getsupportactionbar().setdisplayshowhomeenabled(true); drawerfragment = (fragmentdrawer) getsupportfragmentmanager().findfragmentbyid(r.id.fragment_navigation_drawer); drawerfragment.setup(r.id.fragment_navigation_drawer, (drawerlayout) findviewbyid(r.id.drawer_layout), mtoolbar); drawerfragment.setdrawerlistener(this); // display first navigation drawer view on app launch displayview(0); }
fragmentdrawer.java
this class draws menu need.
private static string tag = fragmentdrawer.class.getsimplename(); private recyclerview recyclerview; private actionbardrawertoggle mdrawertoggle; private drawerlayout mdrawerlayout; private navigationdraweradapter adapter; private view containerview; private static string[] titles = null; private fragmentdrawerlistener drawerlistener; public fragmentdrawer() { } public void setdrawerlistener(fragmentdrawerlistener listener) { this.drawerlistener = listener; } public static list<navdraweritem> getdata() { list<navdraweritem> data = new arraylist<>(); // preparing navigation drawer items (int = 0; < titles.length; i++) { navdraweritem navitem = new navdraweritem(); navitem.settitle(titles[i]); data.add(navitem); } return data; } @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); // drawer labels titles = getactivity().getresources().getstringarray(r.array.nav_drawer_labels); } @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { // inflating view layout view layout = inflater.inflate(r.layout.fragment_navigation_drawer, container, false); recyclerview = (recyclerview) layout.findviewbyid(r.id.drawerlist); adapter = new navigationdraweradapter(getactivity(), getdata()); recyclerview.setadapter(adapter); recyclerview.setlayoutmanager(new linearlayoutmanager(getactivity())); recyclerview.addonitemtouchlistener(new recyclertouchlistener(getactivity(), recyclerview, new clicklistener() { @override public void onclick(view view, int position) { drawerlistener.ondraweritemselected(view, position); mdrawerlayout.closedrawer(containerview); } @override public void onlongclick(view view, int position) { } })); return layout; } @suppresslint("newapi") public void setup(int fragmentid, drawerlayout drawerlayout, final toolbar toolbar) { containerview = getactivity().findviewbyid(fragmentid); mdrawerlayout = drawerlayout; mdrawertoggle = new actionbardrawertoggle(getactivity(), drawerlayout, toolbar, r.string.drawer_open, r.string.drawer_close) { @override public void ondraweropened(view drawerview) { super.ondraweropened(drawerview); getactivity().invalidateoptionsmenu(); } @override public void ondrawerclosed(view drawerview) { super.ondrawerclosed(drawerview); getactivity().invalidateoptionsmenu(); } @override public void ondrawerslide(view drawerview, float slideoffset) { super.ondrawerslide(drawerview, slideoffset); toolbar.setalpha(1 - slideoffset / 2); } }; mdrawerlayout.setdrawerlistener(mdrawertoggle); mdrawerlayout.post(new runnable() { @override public void run() { mdrawertoggle.syncstate(); } }); } public static interface clicklistener { public void onclick(view view, int position); public void onlongclick(view view, int position); } static class recyclertouchlistener implements recyclerview.onitemtouchlistener { private gesturedetector gesturedetector; private clicklistener clicklistener; @suppresslint("newapi") public recyclertouchlistener(context context, final recyclerview recyclerview, final clicklistener clicklistener) { this.clicklistener = clicklistener; gesturedetector = new gesturedetector(context, new gesturedetector.simpleongesturelistener() { @override public boolean onsingletapup(motionevent e) { return true; } @override public void onlongpress(motionevent e) { view child = recyclerview.findchildviewunder(e.getx(), e.gety()); if (child != null && clicklistener != null) { clicklistener.onlongclick(child, recyclerview.getchildposition(child)); } } }); } @override public boolean onintercepttouchevent(recyclerview rv, motionevent e) { view child = rv.findchildviewunder(e.getx(), e.gety()); if (child != null && clicklistener != null && gesturedetector.ontouchevent(e)) { clicklistener.onclick(child, rv.getchildposition(child)); } return false; } @override public void ontouchevent(recyclerview rv, motionevent e) { } @override public void onrequestdisallowintercepttouchevent(boolean arg0) { // todo auto-generated method stub } } public interface fragmentdrawerlistener { public void ondraweritemselected(view view, int position); }
thank you!
create new project,set min target id 10, there auto create appcompat_v7 library,then add appcompat_v7 library @ project.
i have used import v7 library, there has same errors yours,i solved use above method.
Comments
Post a Comment