I am in a bit of a pickle. My SQLiteOpenHelper's onCreate() method takes too long (60+ seconds). To fix this, I need to bundle an already created .db file as an asset. Unfortunately, I have too many Android dependencies in my onCreate() method (Content Values, etc), so I cannot create my .db file on its own without emulating Android.
Here's my plan - create two different SQLiteOpenHelpers - one for the initial database creation that will generate a .db file, and the second openHelper to consume that file. Every end user of my app will only ever use the second openHelper, but my Gradle build script will use the first openHelper.
What type of Gradle logic could be used to accomplish this? The steps would be:
- run the first
SQLiteOpenHelperto capture the.dbfile (maybe use Roblectric to run theonCreate()on the JVM) - copy the
.dbfile to my apps/assetsdirectory - Rebuild my app a final time with the newly generated
.dbfile
Is Gradle even capable of solving something like this?
- Note: I know that this is bad design and I am in circular dependency hell. If I was allowed the time (I am not), I would build the initial
.dbfile as a separate submodule. - Note2: Ultimately, I would like to be able to build my app with
./gradlew clean build
Aucun commentaire:
Enregistrer un commentaire