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

Login Activity Self-Destructing App, Starting the App, Extra Credit (Alternative Login) not working...

Hey,

I'm trying to do the extra credit for the first stage of the Self Destruction app. All I have done so far is setup the new template, named LoginActivity2, when I try to change the intent from ' Intent intent = new Intent(this, LoginActivity.class); ' to Intent intent = new Intent(this, LoginActivity2.class); the app crashes on loading.

I have not modified the template at all, but I think it should atleast load the templated activity.

The logcat reports:

12-04 01:52:20.808    3254-3254/ribbit.milantailor.com.ribbit D/dalvikvm﹕ GC_FOR_ALLOC freed 53K, 3% free 3765K/3880K, paused 2ms, total 2ms
12-04 01:52:20.812    3254-3254/ribbit.milantailor.com.ribbit D/dalvikvm﹕ GC_FOR_ALLOC freed 2K, 3% free 3983K/4104K, paused 2ms, total 2ms
12-04 01:52:20.816    3254-3254/ribbit.milantailor.com.ribbit I/dalvikvm-heap﹕ Grow heap (frag case) to 6.367MB for 2536932-byte allocation
12-04 01:52:20.824    3254-3263/ribbit.milantailor.com.ribbit D/dalvikvm﹕ GC_FOR_ALLOC freed <1K, 2% free 6461K/6584K, paused 8ms, total 8ms
12-04 01:52:21.176    3254-3254/ribbit.milantailor.com.ribbit D/libEGL loaded /system/lib/egl/libEGL_genymotion.so
12-04 01:52:21.176    3254-3254/ribbit.milantailor.com.ribbit D/﹕ HostConnection::get() New Host Connection established 0xb94f7ff8, tid 3254
12-04 01:52:21.200    3254-3254/ribbit.milantailor.com.ribbit D/libEGL loaded /system/lib/egl/libGLESv1_CM_genymotion.so
12-04 01:52:21.200    3254-3254/ribbit.milantailor.com.ribbit D/libEGL loaded /system/lib/egl/libGLESv2_genymotion.so
12-04 01:52:21.264    3254-3254/ribbit.milantailor.com.ribbit W/EGL_genymotion eglSurfaceAttrib not implemented
12-04 01:52:21.264    3254-3254/ribbit.milantailor.com.ribbit E/OpenGLRenderer Getting MAX_TEXTURE_SIZE from GradienCache
12-04 01:52:21.268    3254-3254/ribbit.milantailor.com.ribbit E/OpenGLRenderer MAX_TEXTURE_SIZE: 16384
12-04 01:52:21.276    3254-3254/ribbit.milantailor.com.ribbit E/OpenGLRenderer Getting MAX_TEXTURE_SIZE from Caches::initConstraints()
12-04 01:52:21.276    3254-3254/ribbit.milantailor.com.ribbit E/OpenGLRenderer MAX_TEXTURE_SIZE: 16384
12-04 01:52:21.276    3254-3254/ribbit.milantailor.com.ribbit D/OpenGLRenderer Enabling debug mode 0
12-04 01:52:21.288    3254-3254/ribbit.milantailor.com.ribbit D/AndroidRuntime Shutting down VM
12-04 01:52:21.288    3254-3254/ribbit.milantailor.com.ribbit W/dalvikvm threadid=1: thread exiting with uncaught exception (group=0xa4cbfb20)
12-04 01:52:21.288    3254-3254/ribbit.milantailor.com.ribbit E/AndroidRuntime FATAL EXCEPTION: main
    Process: ribbit.milantailor.com.ribbit, PID: 3254
    java.lang.RuntimeException: Unable to start activity ComponentInfo{ribbit.milantailor.com.ribbit/ribbit.milantailor.com.ribbit.LoginActivity2}: java.lang.NullPointerException
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
            at android.app.ActivityThread.access$800(ActivityThread.java:135)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5001)
            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:785)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.NullPointerException
            at ribbit.milantailor.com.ribbit.LoginActivity2.onCreate(LoginActivity2.java:66)
            at android.app.Activity.performCreate(Activity.java:5231)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
            at android.app.ActivityThread.access$800(ActivityThread.java:135)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5001)
            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:785)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
            at dalvik.system.NativeStart.main(Native Method)

This maybe useful, line 66 of LoginActivity2 is:

        mPasswordView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
                if (id == R.id.login || id == EditorInfo.IME_NULL) {
                    attemptLogin();
                    return true;
                }
                return false;
            }
        });

Thanks.