Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

Gnani Pasupula
Gnani Pasupula
3,915 Points

My app is crashing

Guys i am making my own app after watching some of the tutorials. But due to this code my app is crashing . Tell me the solution .

//Enabling and disabling the start button

    if (fullnamegive != null && fathernamegive != null && dobgive != null && emailgive != null && numbergive != null){
        start.setEnabled(true);
    }

    else{
        start.setEnabled(false);
    }
Gnani Pasupula
Gnani Pasupula
3,915 Points

This is the error log

Process: com.weebly.gnanicg.profile, PID: 27504 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.weebly.gnanicg.profile/com.weebly.gnanicg.profile.MainActivity}: java.lang.NullPointerException at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2342) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2394) at android.app.ActivityThread.access$800(ActivityThread.java:155) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1325) at android.os.Handler.dispatchMessage(Handler.java:110) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:5300) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:830) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:646) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.NullPointerException at com.weebly.gnanicg.profile.MainActivity.onCreate(MainActivity.java:42) at android.app.Activity.performCreate(Activity.java:5264) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2306) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2394)  at android.app.ActivityThread.access$800(ActivityThread.java:155)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1325)  at android.os.Handler.dispatchMessage(Handler.java:110)  at android.os.Looper.loop(Looper.java:193)  at android.app.ActivityThread.main(ActivityThread.java:5300)  at java.lang.reflect.Method.invokeNative(Native Method)  at java.lang.reflect.Method.invoke(Method.java:515)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:830)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:646)  at dalvik.system.NativeStart.main(Native Method)

1 Answer

aakarshrestha
aakarshrestha
6,509 Points

Check the log and see what error it throws. Log should provide what is not working.

Or you can share the log info here.

Happy coding!