MaterialDrawer: Resources$NotFoundException: Resource ID #0x0
Hi.
im trying to implement the standard drawer in my app (the one that shows up when you open the sample app), however i am getting a ResourceNotFoundException and i have no idea why.
this is my code:
IProfile profile = new ProfileDrawerItem().withName("Homer Simpson").withEmail("doh!@gmail.com").withIcon("http://www.yourtv.com.au/img/blog/homer-simpson.jpg");
mHeader = new AccountHeaderBuilder()
.withActivity(this)
.withTranslucentStatusBar(true)
// .withHeaderBackground(R.drawable.header)
.addProfiles(profile)
.withSavedInstance(savedInstanceState)
.build();
mDrawer = new DrawerBuilder()
.withActivity(this)
.withHasStableIds(true)
.withAccountHeader(mHeader)
.addDrawerItems(new PrimaryDrawerItem().withName("inbox").withIdentifier(DRAWERITEM_ID_INBOX).withSelectable(false),
new PrimaryDrawerItem().withName("therapists").withIdentifier(DRAWERITEM_ID_THERAPISTS).withSelectable(false),
new PrimaryDrawerItem().withName("my treatments").withIdentifier(DRAWERITEM_ID_MYTREATMENTS).withSelectable(false),
new PrimaryDrawerItem().withName("evaluation").withIdentifier(DRAWERITEM_ID_EVALUATION).withSelectable(false),
new PrimaryDrawerItem().withName("diagnosis").withIdentifier(DRAWERITEM_ID_DIAGNOSIS).withSelectable(false),
new PrimaryDrawerItem().withName("calendar").withIdentifier(DRAWERITEM_ID_CALENDAR).withSelectable(false),
new PrimaryDrawerItem().withName("logout").withIdentifier(DRAWERITEM_ID_LOGOUT).withSelectable(false))
.withOnDrawerItemClickListener(this)
.withSavedInstance(savedInstanceState)
.withShowDrawerOnFirstLaunch(true)
.build();
and this is the exception im getting when trying to run:
03-16 17:33:00.454 5022-5022/com.example.videotherapystudio E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.videotherapystudio, PID: 5022
android.content.res.Resources$NotFoundException: Resource ID #0x0
at android.content.res.Resources.getValue(Resources.java:1269)
at android.content.res.Resources.getDrawable(Resources.java:769)
at android.content.Context.getDrawable(Context.java:402)
at android.support.v4.content.ContextCompatApi21.getDrawable(ContextCompatApi21.java:26)
at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:321)
at com.mikepenz.materialize.util.UIUtils.getSelectableBackground(UIUtils.java:353)
at com.mikepenz.materialize.util.UIUtils.getSelectableBackground(UIUtils.java:285)
at com.mikepenz.materialdrawer.model.BasePrimaryDrawerItem.bindViewHelper(BasePrimaryDrawerItem.java:78)
at com.mikepenz.materialdrawer.model.PrimaryDrawerItem.bindView(PrimaryDrawerItem.java:69)
at com.mikepenz.materialdrawer.model.PrimaryDrawerItem.bindView(PrimaryDrawerItem.java:18)
at com.mikepenz.fastadapter.FastAdapter$OnBindViewHolderListenerImpl.onBindViewHolder(FastAdapter.java:1287)
at com.mikepenz.fastadapter.FastAdapter.onBindViewHolder(FastAdapter.java:413)
at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:5453)
at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:5486)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4723)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4599)
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:1988)
at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1384)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1347)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:574)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3003)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2881)
at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3265)
at android.view.View.layout(View.java:15631)
at android.view.ViewGroup.layout(ViewGroup.java:4966)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1076)
at android.view.View.layout(View.java:15631)
at android.view.ViewGroup.layout(ViewGroup.java:4966)
at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:1211)
at android.view.View.layout(View.java:15631)
at android.view.ViewGroup.layout(ViewGroup.java:4966)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573)
at android.widget.FrameLayout.onLayout(FrameLayout.java:508)
at android.view.View.layout(View.java:15631)
at android.view.ViewGroup.layout(ViewGroup.java:4966)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1705)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1559)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1468)
at android.view.View.layout(View.java:15631)
at android.view.ViewGroup.layout(ViewGroup.java:4966)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573)
at android.widget.FrameLayout.onLayout(FrameLayout.java:508)
at android.view.View.layout(View.java:15631)
at android.view.ViewGroup.layout(ViewGroup.java:4966)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2101)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1858)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1077)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5845)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
at android.view.Choreographer.doCallbacks(Choreographer.java:580)
at android.view.Choreographer.doFrame(Choreographer.java:550)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.
i tried to eliminate this error by removing anything that calls for a resource (e.g. no drawable background for header, and hard-coded strings) but to no use… still getting the above error.
i am using version 5.1.3
please help
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 18 (10 by maintainers)
Commits related to this issue
- Update README.md * add note that at least a theme which has the `AppCompat` theme as parent is required * Related to #1102 — committed to mikepenz/MaterialDrawer by mikepenz 8 years ago
I just had exactly the same problem and in my case it was solvable by adding a
android:theme="@style/MaterialDrawerTheme.*"attribute to the activity tag in the AndroidManifest.xml. Maybe the same in your case? The cause was hard to find though and i was only lucky, because the stack trace is too long. Maybe consider it a bug…?btw: Awesome library, thank you so much! 😃 Cheers