Introduction
Hi, I have a complex app with more than one Realm (because of sandboxing) and Realms are stored on External Storage. Until recently I was stuck at v1.0.1 because of various problems that were fixed ;)
But now I'm facing a new problem, the compact phase (which is started before opening the realm) is crashing the whole app. Even if I'm catching the RealmError, a native crash occurs afterwards.
Goal
Compact Realm before opening it, the Realm exists and is writable.
Expected Results
No explosion
Actual Results
io.realm.exceptions.RealmError: Unrecoverable error. Read-only file system in /home/cc/repo/realm/realm-java-release/realm/realm-library/src/main/cpp/io_realm_internal_SharedRealm.cpp line 414
at io.realm.internal.SharedRealm.nativeCompact(Native Method)
at io.realm.internal.SharedRealm.compact(SharedRealm.java:327)
at io.realm.BaseRealm.compactRealm(BaseRealm.java:586)
at io.realm.Realm.compactRealm(Realm.java:1612)
Steps & Code to Reproduce
Simple AndroidTestCase
public class RealmExternalTest extends AndroidTestCase {
@Override
protected void setUp() throws Exception {
Realm.init(getContext());
}
@Override
protected void tearDown() throws Exception {
}
public void testRealmCompactExternal() {
File directory = getContext().getExternalFilesDir(null);
directory.mkdirs();
assertTrue(directory.exists());
RealmConfiguration config = new RealmConfiguration.Builder().directory(directory).name("somerealm.realm").build();
Realm realm = Realm.getInstance(config);
File realmFile = new File(config.getPath());
assertTrue(realmFile.exists() && realmFile.canWrite());
{ // simple read/write
Test test = new Test();
realm.beginTransaction();
try {
realm.copyToRealm(test);
realm.commitTransaction();
} catch (Exception e) {
realm.cancelTransaction();
fail();
}
assertTrue(realm.where(Test.class).count() > 0);
}
realm.close();
assertTrue(Realm.compactRealm(config));
}
}
The whole test is passing, except the last line throwing the above exception :/
Version of Realm and tooling
Realm version(s): 2.3.0
Realm sync feature enabled: no
Android Studio version: 2.2.3
Which Android version and device: Samsung Galaxy Tab S2 (SM-T710) 6.0.1
Introduction
Hi, I have a complex app with more than one Realm (because of sandboxing) and Realms are stored on External Storage. Until recently I was stuck at v1.0.1 because of various problems that were fixed ;)
But now I'm facing a new problem, the
compactphase (which is started before opening the realm) is crashing the whole app. Even if I'm catching theRealmError, a native crash occurs afterwards.Goal
Compact Realm before opening it, the Realm exists and is writable.
Expected Results
No explosion
Actual Results
Steps & Code to Reproduce
Simple AndroidTestCase
The whole test is passing, except the last line throwing the above exception :/
Version of Realm and tooling
Realm version(s): 2.3.0
Realm sync feature enabled: no
Android Studio version: 2.2.3
Which Android version and device: Samsung Galaxy Tab S2 (SM-T710) 6.0.1