I have the following data structure in my current Firebase real-time DB:
public class E {
public int x;
public int y;
public int x;
}
This database is currently in use by my Android application which is already used by users in production.
I want to add a new member to the class (String z) as shown below:
public class E {
public int x;
public int y;
public int x;
public String z;
}
When using an old version of the app I see this error in logcat:
W/ClassMapper: No setter/field for z found on class com.me.you.E
And the application is stuck.
I have included a Database version check before the application starts to guide users to update their application, but was hoping not to need it in this specific case.
Is there any versioning possible on the data? Any other suggestion?
To get rid of that warning message, annotate your class with @IgnoreExtraProperties
:
@IgnoreExtraProperties
public class E {
public int x;
public int y;
public int x;
}
See the reference documentation for the IgnoreExtraProperties
annotation:
Properties that don't map to class fields are ignored when serializing to a class annotated with this annotation.
As Doug commented, beyond this simple change to get rid of the warning, data migration on Firebase is a complex topic, which is impossible to answer in a single Stack Overflow question. But we can try to help with specific problems, such as warnings and crashes. If your application still gets stuck on loading, please post a minimal complete verifiable way to reproduce the problem.