I’m using this code to get Realm Instance on MainActivity:

App app = new App(new AppConfiguration.Builder("application-0-vaocb").build());
SyncConfiguration config = new SyncConfiguration.Builder(app.currentUser()).build();
Realm realm = Realm.getInstance(config);

And using the exact same code on another activity CustomerActivity:

App app = new App(new AppConfiguration.Builder("application-0-vaocb").build());
SyncConfiguration config = new SyncConfiguration.Builder(app.currentUser()).build();
Realm realm = Realm.getInstance(config);

Still getting this error:

java.lang.IllegalArgumentException: Configurations cannot be different if used to open the same file. 
 Cached configuration: 
  realmDirectory: /data/user/0/com.in/files/mongodb-realm/application-0/65566a52ab8ce3e71ebdcf22
  realmFileName : default.realm
  canonicalPath: /data/user/0/com.in/files/mongodb-realm/application-0/65566a52ab8ce3e71ebdcf22/default.realm
  key: [length: 0]
  schemaVersion: 0
  migration: null
  deleteRealmIfMigrationNeeded: false
  durability: FULL
  schemaMediator: io.realm.DefaultRealmModuleMediator@fcf6dfb
  readOnly: false
  compactOnLaunch: null
  maxNumberOfActiveVersions: 9223372036854775807
  serverUrl: wss://realm.mongodb.com/
  user: io.realm.mongodb.User@95acac88
  errorHandler: io.realm.mongodb.AppConfiguration$Builder$1@fcda401
  initialSubscriptions: null
  deleteRealmOnLogout: false
  syncClientValidateSsl: true
  serverCertificateAssetName: null
  serverCertificateFilePath: null
  waitForInitialData: false
  initialDataTimeoutMillis: 9223372036854775807
  sessionStopPolicy: AFTER_CHANGES_UPLOADED
  syncUrlPrefix: /api/client/v2.0/app/application-0-vaocb/realm-sync
  partitionValue: null
    
 New configuration: 
  realmDirectory: /data/user/0/com.in/files/mongodb-realm/application-0/65566a52ab8ce3e71ebdcf22
  realmFileName : default.realm
  canonicalPath: /data/user/0/com.in/files/mongodb-realm/application-0/65566a52ab8ce3e71ebdcf22/default.realm
  key: [length: 0]
  schemaVersion: 0
  migration: null
  deleteRealmIfMigrationNeeded: false
  durability: FULL
  schemaMediator: io.realm.DefaultRealmModuleMediator@fcf6dfb
  readOnly: false
  compactOnLaunch: null
  maxNumberOfActiveVersions: 9223372036854775807
  serverUrl: wss://realm.mongodb.com/
  user: io.realm.mongodb.User@e4199dbc
  errorHandler: io.realm.mongodb.AppConfiguration$Builder$1@7bbf883
  initialSubscriptions: null
  deleteRealmOnLogout: false
  syncClientValidateSsl: true
  serverCertificateAssetName: null
  serverCertificateFilePath: null
  waitForInitialData: false
  initialDataTimeoutMillis: 9223372036854775807
  sessionStopPolicy: AFTER_CHANGES_UPLOADED
  syncUrlPrefix: /api/client/v2.0/app/application-0-vaocb/realm-sync
  partitionValue: null

Here is the diffchecker screenshot:

Hi @hkchakladar,

Have you tried to not re-declare the app, but just re-use the same, kept as global? Having a different app, hence a different currentUser() object, may be the issue here.

Hi @Paolo_Manna ,

How to do that?

It looks like the error handler registration counts towards the hash of the configuration. Try removing the error handler…

Hi @Jason_Whetton , I have not registered any Error handlers.

Is problem solved? I am doubt can i ask a question?

i have same problem here …

Hi @Sajjad_Amini and @Arturo_Martinez ,

We don’t know whether the problem in the description was solved, as the OP never replied to our suggestion (i.e. only use ONE app, don’t re-create the app every time you try to access the DB, as that can leave around multiple users that would conflict when accessing the same DB)

Hi @Sajjad_Amini
have you been able to resolve the issue?

I am using ONE app and not recreating it. Still facing the same error. Can you please suggest me other solution?

Hi @hkchakladar
I am facing this issue. Have you been able to find out what is the problem and how to fix it?