Crash on deleting realm after migrating to 4.1.1 from 3.3.1
See original GitHub issueWe are using below code to to open realm instance. It used to work fine for version 3.1.1 Idea is that we have some migrations for last two three versions but for version before that we dont so it throws exception or in case migration fails we delete that current realm and open again.
this used to work fine in 3.1.1 how ever we just upgraded to 4.1.1 last sprint and after it we are seeing a-lot of crashes.
Realm.init(context);
RealmConfiguration configuration = new RealmConfiguration.Builder()
.schemaVersion(<version>)
.migration(<migrator>)
.build();
try {
defaultInstance = Realm.getInstance(configuration );
} catch (IllegalArgumentException | IllegalStateException | RealmMigrationNeededException ex) {
Realm.deleteRealm(configuration);
defaultInstance = Realm.getInstance(configuration);
}
Expected Results
it should not crash
Actual Results
This is the exception we are getting
Caused by java.lang.IllegalStateException: It's not allowed to delete the file associated with an open Realm. Remember to close() all the instances of the Realm before deleting its file: /data/data/com.x.x/files/default.realm
at io.realm.Realm.io.realm.BaseRealm.deleteRealm(SourceFile:14624)
at com.x.x.x.RealmManager.getDefaultInstance(SourceFile:52)
Version of Realm and tooling
Realm version(s): 4.1.1
Realm sync feature enabled: yes/no
Android Studio version: 3.0.0
Which Android version and device: no specific version happening on almost every os
Issue Analytics
- State:
- Created 6 years ago
- Comments:14 (7 by maintainers)
Top Results From Across the Web
Realm: Create reactive mobile apps in a fraction ... - MongoDB
The path to a local Realm's file location; The migration function, if a Realm's schemas change between revisions and must be updated; Configuring...
Read more >I have trouble with the latest Android Studio Gradle Update 3.3.1
The question is not related to 'Butterknife' at all as because after removing it's dependencies, the warnings were still there.
Read more >Hazelcast IMDG Release Notes
Hazelcast IMDG Open Source Edition Release Notes lists the new features, enhancements and fixed issues for each Hazelcast IMDG release.
Read more >Create reactive mobile apps in a fraction of the time - Realm
Apps using Realm can target: iOS 8 or later, OS X 10.9 or later & WatchKit. ... Make sure that you remove the...
Read more >1.24 - Foreman :: Manual
The Foreman installer uses Puppet (4 or later required) to install Foreman. ... Remove DNS entries from FreeIPA when deleting hosts from realm....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I just tried to write the following unit test:
It parses. Have you tried printing the values of
Realm.getGlobalInstanceCount(config)as the first thing in yourtry/catch?in 4.2.1, no date at the moment, i’m waiting for that too =p https://github.com/realm/realm-java/blob/master/CHANGELOG.md