SetReadAccess failed for new ParseObject

I have the following code placed in my app class of my android app:

// Register ParseObject subclasses
ParseObject.registerSubclass(Results.class);

// Set up Parse
Parse.enableLocalDatastore(MyApplication.this);
Parse.initialize(MyApplication.this, PARSE_APP_KEY, PARSE_CLIENT_KEY);
ParseUser.enableAutomaticUser();
ParseACL defaultACL = new ParseACL();
ParseACL.setDefaultACL(defaultACL, true);

      

It seems to work great when I have a fresh install of my application and I create new Results objects. Now if I update my app via Play Store or install it via Android Studio, I get the following error when creating new Results objects or any other ParseObject or subclass:

java.lang.IllegalArgumentException: cannot setReadAccess for a user with null id

      

Is this a bug with Parse? I get the same results with the Offline Todo example.

+3


source to share


2 answers


You need to save the current user.

// Register ParseObject subclasses
ParseObject.registerSubclass(Results.class);

// Set up Parse
Parse.enableLocalDatastore(MyApplication.this);
Parse.initialize(MyApplication.this, PARSE_APP_KEY, PARSE_CLIENT_KEY);
ParseUser.enableAutomaticUser();
ParseUser.getCurrentUser().saveInBackground(); // <--- This Line
ParseACL defaultACL = new ParseACL();
ParseACL.setDefaultACL(defaultACL, true);

      



Not really sure about my syntax, I only did it in Swift.

+6


source


uninstall the app from your device and install it again. it should work.

here is my setup

    //Parser App Crash Report
    ParseCrashReporting.enable(this); //THIS is to test only =>  throw new RuntimeException("Test Exception!");

    // Enable Local Datastore.
    Parse.enableLocalDatastore(this);

    // Initialise
    Parse.initialize(this, PARSE_APP_ID, PARSE_CLIENT_KEY);


    ParseUser.enableAutomaticUser();
    ParseUser.getCurrentUser().saveInBackground();
    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);

      



then check:

ParseObject testObject = new ParseObject("TestObject");
testObject.put("foo", "bar");
testObject.put("2", "2");
testObject.put("3", "3");
testObject.saveInBackground();

      

+3


source







All Articles