You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Library contains database tables and class to create the corresponding RealmConfiguration. RealmConfiguration creation:
public final class DatabaseConfiguration {
//
// module
//
@RealmModule(library = true, allClasses = true)
private static final class module_t {}
private static final long SCHEMA = 10;
private static final module_t module_ = new module_t();
@Nullable
private final String location_;
@NonNull
private final String name_;
public DatabaseConfiguration(@NonNull final String input) {
final File path = new File(input);
location_ = path.getParent();
name_ = path.getName();
}
@NonNull
public RealmConfiguration run() {
final RealmConfiguration.Builder builder = new RealmConfiguration
.Builder()
.name(name_)
.schemaVersion(SCHEMA)
.deleteRealmIfMigrationNeeded()
.modules(module_);
if(null != location_)
builder.directory(new File(location_));
return builder.build();
}
}
Application contains several Realm databases with corresponding classes producing RealmConfiguration, but without @RealmModule definition. With this configuration database configuration from the library contains expected scheme. Schema verified by the following code in the app's Application class immediately Realm initialization (see log A):
Realm.init(context);
Realm.setDefaultConfiguration(new RealmConfiguration.Builder().
name("local.realm").
schemaVersion(REALM_SCHEMA).
deleteRealmIfMigrationNeeded().
compactOnLaunch(new StorageCompactOnLaunch(Application.class, -1007238489)).
build());
if(DEBUG) {
@NonNull final var configuration =
new uk.co.pintent.easymap.poi.converter.data.DatabaseConfiguration("remote_A.realm").run();
final var classes = configuration.getRealmObjectClasses();
log_.debug("remote schema begin");
for(final var current: classes)
log_.debug("schema --> " + current);
log_.debug("remote schema end");
}// if()
I define @RealmModule for any of the app's database configurations without using it:
public final class DatabaseConfiguration {
@RealmModule(classes = { StorageResponse.class, StorageResultRoot.class, StorageResultSuccess.class, StorageSuggestion.class })
private static final class module_t {}
private static final long SCHEMA_VERSION = 1;
@NonNull
private final String name_;
public DatabaseConfiguration(@NonNull final String input) {
name_ = input;
}
@NonNull
public RealmConfiguration run() {
return new io.realm.RealmConfiguration.Builder()
.name(name_)
.schemaVersion(SCHEMA_VERSION)
.deleteRealmIfMigrationNeeded()
.build();
}
}
After this database schema from the library contains classes defined in the application's @RealmModule, see log B.
This confirms that schema definition in the library effectively gets replaced by schema defined in the application.
@andriy-svirskyy This seem to be because the two @RealmModules have the same class name (module_t). Created #7860 with more details of the internals. As a work around you can just use different class names for your @RealmModules.
How frequently does the bug occur?
Always
Description
Library contains database tables and class to create the corresponding RealmConfiguration. RealmConfiguration creation:
Application contains several Realm databases with corresponding classes producing RealmConfiguration, but without @RealmModule definition. With this configuration database configuration from the library contains expected scheme. Schema verified by the following code in the app's Application class immediately Realm initialization (see log A):
I define @RealmModule for any of the app's database configurations without using it:
After this database schema from the library contains classes defined in the application's @RealmModule, see log B.
This confirms that schema definition in the library effectively gets replaced by schema defined in the application.
Stacktrace & log output
Can you reproduce the bug?
Sometimes
Reproduction Steps
Bug is reproduced within the main application only and cannot be reproduced with test application.
Version
io.realm:realm-gradle-plugin:10.16.1
What Atlas App Services are you using?
Local Database only
Are you using encryption?
No
Platform OS and version(s)
Android API 26
Build environment
Android Studio version: 2022.3.1 Patch 2
Application:
Android Build Tools version: 33.0.2
Gradle version: com.android.tools.build:gradle:7.4.2
Library:
Gradle version: 8.0, plugin 8.1.1
The text was updated successfully, but these errors were encountered: