Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm trying to add signin/signup functionality in my NavigationDrawer app but I'm running into this problem when I compile the project.

Java
"FATAL EXCEPTION Caused by: java.lang.NullPointerException at MainActivity.onCreate(MainActivity.java:111)"


Here's that line
Java
mDrawerLayout.setDrawerShadow(drawable.drawer_shadow,GravityCompat.START);


Here's a snippet of the code
Java
...
dataList = new ArrayList<>();
mTitle = mDrawerTitle = getTitle();
mDrawerList = (ListView) findViewById(id.left_drawer);
mDrawerLayout = (DrawerLayout) findViewById(id.drawer_layout);
mDrawerLayout.setDrawerShadow(drawable.drawer_shadow,GravityCompat.START);
...


I'm not sure how a NullPointerException is being thrown on that line since the drawer_shadow image exists in my drawable folder.
Posted
Updated 31-May-15 17:45pm
v2
Comments
Richard MacCutchan 1-Jun-15 7:04am    
Step through the code with the debugger to identify which reference is null.
pyler 2-Jun-15 0:22am    
for some reason the debugger hangs whenever I run this project so I can't really findout what's going wrong with my code. Any other suggestions?
Richard MacCutchan 2-Jun-15 3:51am    
Well you know where the exception happens so you just need to track back through the code checking that each method call returns valid results. Add some debug code to verify the value of each reference as it runs through the code. You also need to investigate what is causing the debugger to hang.
pyler 2-Jun-15 23:14pm    
Solved it, thanks!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900