我正在尝试同步Android手机上的Realm数据库和本地Realm Objectserver,类似于文档中的RealmsTasks示例。我正在使用此代码:
String authURL = "http://localhost:9080/auth";
SyncCredentials myCredentials = SyncCredentials.usernamePassword(
"...", "...", false); //user is in Realm database
SyncUser.loginAsync(myCredentials, authURL, this);
Log.i("TINGLE","credentials checked");
SyncConfiguration defaultConfig = new SyncConfiguration.Builder(
currentUser(),
"http://localhost:9080/~/realmtingle").build();
Realm.setDefaultConfiguration(defaultConfig);
但是,对SyncConfiguration.Builder的调用给出了一个例外。错误可能是路径" http://localhost:9080/~/realmtingle",但无法找到有关Realm文档中路径的指南。
例外是: ....
Caused by: java.lang.IllegalArgumentException: Invalid scheme: http
at io.realm.SyncConfiguration$Builder.validateAndSet(SyncConfiguration.java:320)
at io.realm.SyncConfiguration$Builder.<init>(SyncConfiguration.java:293)
at io.realm.SyncConfiguration$Builder.<init>(SyncConfiguration.java:280)
at dk.staunstrups.tingle.TingleActivity.setUpRealmSync(TingleActivity.java:74)
at dk.staunstrups.tingle.TingleActivity.onCreate(TingleActivity.java:38)
...
答案 0 :(得分:2)
领域网址应使用realm:
或realms:
。它只是使用http
的身份验证。以下应该有效:
String authURL = "http://localhost:9080/auth";
SyncCredentials myCredentials = SyncCredentials.usernamePassword(
"...", "...", false); //user is in Realm database
SyncUser.loginAsync(myCredentials, authURL, this);
Log.i("TINGLE","credentials checked");
SyncConfiguration defaultConfig = new SyncConfiguration.Builder(
currentUser(),
"realm://localhost:9080/~/realmtingle").build();
Realm.setDefaultConfiguration(defaultConfig);