spotify / ruler

Gradle plugin which helps you analyze the size of your Android apps.
Apache License 2.0
1.13k stars 58 forks source link

Support verification of download and install size #168

Open MrHadiSatrio opened 1 month ago

MrHadiSatrio commented 1 month ago

What has changed

Ruler now supports verification of AAB download and install sizes against user-defined thresholds. This new feature allows developers to ensure their app bundles meet size requirements before deployment. Example configuration:

ruler {
    // Other configurations...
    verification {
        downloadSizeThreshold = 2 * 1024 * 1024 // 2 MB in bytes
        installSizeThreshold = 2 * 1024 * 1024 // 2 MB in bytes
    }
}

If the AAB exceeds either threshold during the analyze<Variant>Bundle task, Ruler will throw a VerificationException:

Execution failed for task ':sample:app:analyzeDebugBundle'.
> com.spotify.ruler.common.verification.VerificationException: Download size exceeds the threshold by 1107079 bytes.

Why was it changed

If an end user requires such functionality, they would currently have to either implement a processor for Ruler's output files or depend on other tools (e.g., apkanalyzer). Having this built into Ruler would help centralize that logic, thus reducing potential duplication.

MrHadiSatrio commented 1 month ago

Thanks for the review, @ViktorPetrovski.

Unfortunately, CI seems to fail with a reason unrelated to this changeset. I made an attempt to fix that through #169.

MrHadiSatrio commented 1 month ago

Accidentally deleted this branch on my fork, my bad. Reopening the PR.