Search code examples
androidandroid-roomandroid-room-migration

Should We Remove The Room Migration DataBase Generated Schema files before App relase?


we are starting the room auto migrations.. now we are thinking is it possible to remove the generated Json Files of our database versions from relase the apk? im asking this because we have db structure for previous version and new version have its own db structure stored , and i can see these schema.jsnon files are only used in compile time to compare the db schema changes ..so is there a way to delete those files and generate a build?? the problem is each json file is almost 70kb and if there are like 100 versions its almost 7 mb.. which is not accepted from a design view and all the data is reduntant so should these shema.json files go through apk release???

i tried to remove those files and genrate a build but thats not happening,any one can help me in regarding this?


Solution

  • The generated json wont be part of generated build , but they are required for genrating the apk.

    Practically -> I manually added 5 mb very large json to the schema folder so we can see the generated apk size difference , but its exactly the same.

    Theoretically -> In the case of Room, the generated schema files are typically used during compilation to generate database-related code. Once the code generation is complete, the generated Java files are compiled along with the rest of your project's source code.

    However, the schema files themselves (which are typically JSON files) are not needed at runtime. They are used by the Room annotation processor during compilation to generate the necessary database-related code but are not required by the application when it runs on a device.

    Therefore, schema files are generally not included in the final APK. They are considered part of the build-time artifacts rather than the runtime assets. If you want to inspect or access the schema files during development or debugging, you might keep them in the project directory for reference, but they are not necessary for the functioning of the compiled application.