I have a directory within my assets folder with json for a database.
assets/database/database_1/locations.json
When using minifyEnabled true
, it's removing those assets as it doesn't think they're used.
How do I tell ProGuard that they're used?
I have a directory within my assets folder with json for a database.
assets/database/database_1/locations.json
When using minifyEnabled true
, it's removing those assets as it doesn't think they're used.
How do I tell ProGuard that they're used?
It turns out minifyEnabled true
does not remove any assets, it's only for code optimization and obfuscates the remaining classes.
The issue was I'm using Gson with my database models without @SerializedName
and with the obfuscation it wouldn't be able to bind the values.
dataclass MyModel( val myName : String )
would turn into: (or something more obfuscated)
dataclass XYZ( val 123 : String )
And then Gson could not find the value "myName" to put the JSON.
To solve this, you have two solutions.
@SerializedName
to each variable.useProguard false
.It is not ProGuard who is doing this kind of optimization. See https://developer.android.com/studio/build/shrink-code.html#keep-resources. That being said, assets should not be affected, just resources.
minifyEnabled=true removes all my gpx files stored in assets folder. The same project rebuild with minifyEnabled=false keeps all the gpx-files in the assets f