Open zeekhuge opened 6 years ago
Interestingly enough, replacing
ParseInstallation pi = ParseInstallation.getCurrentInstallation();
pi.put("GCMSenderId","xxxxxxxx");
pi.saveInBackground();
with ParseInstallation.getCurrentInstallation().saveInBackground();
kind of solves the problem.
I'd still consider it as a bug.
I can work on a PR, with some guidance on what is happening and where to look for the bug in the SDK code.
Obviously enough, the workaround would be something like this :
TheApplication.java
public class TheApplication extends Application {
private final String TAG = TheApplication.class.getSimpleName();
@Override
public void onCreate () {
super.onCreate();
Log.d(TAG, "inside onCreate");
Parse.setLogLevel(Parse.LOG_LEVEL_VERBOSE);
Parse.initialize(
new Parse.Configuration.Builder(this)
.applicationId("xxxxxxxxxxxxxxxxxxxx")
.server("xxxxxxxxxxxxxxxxx")
.enableLocalDataStore()
.clientKey("")
.build()
);
ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
int myPid = android.os.Process.myPid();
String myProcessName = "";
for (ActivityManager.RunningAppProcessInfo ri : am.getRunningAppProcesses()) {
if (ri.pid == myPid) {
myProcessName = ri.processName;
break;
}
}
if (!myProcessName.equals(getPackageName() + getString(R.string.test_process))) {
Log.d(TAG, "Setting up parseInstallation for process " + myProcessName);
ParseInstallation pi = ParseInstallation.getCurrentInstallation();
pi.put("GCMSenderId","xxxxxx");
pi.saveInBackground();
}
}
Version Parse SDK version : 'com.parse:parse-android:1.16.1` compileSdkVersion : 26 minSdkVersion 19
PROBLEM I have an app in which there are more than one processes. I am developing it, so I have to make changes, install and reinstall it on the AVD. I noticed that after a few installations, I was not able to grab the
User
object, although I had logged in already and a few other weird things ...I dug deep and discovered that the
_Installation
class was completely missing from theParseOfflineStore
database file.Went deeper and discovered that the
_Installation
object was there in the database at the start, and it was getting removed somehow after a few (most of the time, only 2) iterations of reinstalling it on the AVD. Further, discovered that it was because of having 2 different processes.HOW TO REPRODUCE This test application has a main-activity and one service which is being started in a different
Process
(usingandroid:process
tag in the manifest).TheApplication.java
MyService.java
MainActivity.java :
AndroidManifest.xml
Note that
MyService
is on a different process:test
testScript.sh (extra fun)
The script simply re-installs the app, starts it, waits for a few seconds, fetches the
ParseOfflineStore
file, checks if it has the_Installation
class and loops over these steps till the_Installation
object is there.Compile the debug app and run the
testScript.sh
with right parameters. After a few iterations the script will stop which would mean that the_Installation
object disappeared from theParseOfflineStore