Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
348 views
in Technique[技术] by (71.8m points)

android - SetReadAccess error for new ParseObject

I have the following code placed in my application class of an Android app of mine:

// 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);

This seems to work great whenever I have a fresh install of my app and I create new Results objects. Now, if I update my app via the Play store, or install over it via Android Studio, I get the following error whenever new Results objects, or any other ParseObject or subclass thereof, are created:

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You need to make sure 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 entirely sure about my syntax, I've only done it in Swift.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...