Click here to Skip to main content
15,908,673 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am developing a simple login in android using parse, when i try to run the app in the emulator it crashes and shows "Unfortunately parse login tutorial has stopped" how can i rectify this

See the stack trace below
02-14 16:41:01.518    1108-1108/com.example.akinyemi.parselogintutorial E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.example.akinyemi.parselogintutorial, PID: 1108
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.akinyemi.parselogintutorial/com.example.akinyemi.parselogintutorial.MyActivity}: java.lang.NullPointerException

see the code below
MyActivity.java
Java
public class MyActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        Parse.initialize(this, "Oej48di7dmNFQ41jnW3AO980BiWG9hLjJNQDhMxn", "CaegN9WONiI3p1F99EDFDlKSzQpuTomFejSSBPAx");

        // Determine whether the current user is an anonymous user
        if (ParseAnonymousUtils.isLinked(ParseUser.getCurrentUser())) {
// If user is anonymous, send the user to LoginSignupActivity.class
            Intent intent = new Intent(MyActivity.this,
                    LoginSignupActivity.class);
            startActivity(intent);
            finish();
        } else {
// If current user is NOT anonymous user
// Get current user data from Parse.com
            ParseUser currentUser = ParseUser.getCurrentUser();
            if (currentUser != null) {
// Send logged in users to Welcome.class
                Intent intent = new Intent(MyActivity.this, Welcome.class);
                startActivity(intent);
                finish();
            } else {
// Send user to LoginSignupActivity.class
                Intent intent = new Intent(MyActivity.this,
                        LoginSignupActivity.class);
                startActivity(intent);
                finish();
            }
        }
    }
	
ParseApplication.java

public class ParseApplication extends Application {

    public static final String YOUR_APPLICATION_ID = "Oej48di7dmNFQ41jnW3AO980BiWG9hLjJNQDhMxn";
    public static final String YOUR_CLIENT_KEY = "CaegN9WONiI3p1F99EDFDlKSzQpuTomFejSSBPAx";


    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate();

        // Add your initialization code here
        Parse.initialize(this, "Oej48di7dmNFQ41jnW3AO980BiWG9hLjJNQDhMxn", "CaegN9WONiI3p1F99EDFDlKSzQpuTomFejSSBPAx");

        ParseUser.enableAutomaticUser();
        ParseACL defaultACL = new ParseACL();

        // If you would like all objects to be private by default, remove this
        // line.
        defaultACL.setPublicReadAccess(true);

        ParseACL.setDefaultACL(defaultACL, true);
    }
}
Posted
Updated 15-Feb-15 6:04am
v2
Comments
Richard MacCutchan 15-Feb-15 12:05pm    
The stack trace is telling you what the problem is. you should use your debugger or remaining debug log messages to identify where it occurs and check the values of variables at that point.
Member 10627743 15-Feb-15 17:01pm    
Thank you for the reply i have read the stack trace i dont seem to find the solution this is the full stack trace kindly look at it

02-15 15:46:05.480 1147-1147/com.example.akinyemi.parselogintutorial E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.akinyemi.parselogintutorial, PID: 1147
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.akinyemi.parselogintutorial/com.example.akinyemi.parselogintutorial.MyActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
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:5017)
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:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.parse.ParseAnonymousUtils.isLinked(ParseAnonymousUtils.java:50)
at com.example.akinyemi.parselogintutorial.MyActivity.onCreate(MyActivity.java:26)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
            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:5017)
            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:779)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
            at dalvik.system.NativeStart.main(Native Method)
02-15 15:45:59.200 1147-1147/com.example.akinyemi.parselogintutorial D/dalvikvm﹕ Not late-enabling CheckJNI (already on)
02-15 15:46:05.270 1147-1147/com.example.akinyemi.parselogintutorial D/AndroidRuntime﹕ Shutting down VM
02-15 15:46:05.270 1147-1147/com.example.akinyemi.parselogintutorial W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0xb3a2aba8)
02-15 15:47:12.420 1147-1147/com.example.akinyemi.parselogintutorial I/Process﹕ Sending signal. PID: 1147 SIG: 9
device offline
Richard MacCutchan 16-Feb-15 3:33am    
That is not what I suggested. It does not explain exactly where the NullPointerException occurs or what variable has not been initialised. Use your debugger to trace the execution path to identify the problem.
Member 10627743 16-Feb-15 4:11am    
ok thank you very much for your time

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