0

I am new to parse.com and android studio. I tried to create a table in parse by simply giving some test data but when the app runs the emulator says "unfortunately the app has stopped".

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import com.parse.Parse;
import com.parse.ParseObject;
public class fresh_app extends Activity {
    Button b1;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_fresh_app);
        // Enable Local Datastore.
        Parse.enableLocalDatastore(this);

        b1=(Button)findViewById(R.id.button);
        b1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ParseObject testObject = new ParseObject("TestObject");
                testObject.put("foo", "bar");
                testObject.saveInBackground();
            }
        });
    }

The gradle dependicies are :

compile files('libs/Parse-1.10.3/Parse-1.10.3.jar')
    compile 'com.parse.bolts:bolts-android:1.+'
4
  • 1
    you need to post your log Commented Oct 26, 2015 at 8:10
  • post your logcat pls Commented Oct 26, 2015 at 8:11
  • see LogCat for the StackTrace of the exception. It will show where is the problem Commented Oct 26, 2015 at 8:11
  • --------- beginning of crash 10-26 17:54:57.293 1933-1933/com.example.anand.fresh_ap E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: com.example.anand.fresh_ap, PID: 1933 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.anand.fresh_ap/com.example.anand.fresh_ap.fresh_app}: java.lang.IllegalStateException: Parse#enableLocalDatastore(Context) must be invoked before Parse#initialize(Context) at os.ZygoteInit.main(ZygoteInit.java:694) @VladMatvienko @sakir @Wesley this is what my logcat says Commented Oct 26, 2015 at 12:28

1 Answer 1

1

Okay, LogCat said it all - You need to put Parse.enableLocalDatastore(this); before Parse.initialize in Your class that extends Application (inside onCreate() ):

public class ParseApp extends Application{

@Override
public void onCreate(){
    Parse.enableLocalDatastore(this);
    Parse.initialize(this, key1, key2);
}
}

Also, no need for compiling files - You could just do: compile 'com.parse:parse-android:1.10.3'

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.