Skip to content

[TECHNICAL] DEX code optimisation is below Google threshold #5029

Closed

Activity

  1. jesmrec commented on Oct 21, 2026

    @jesmrec
    MemberAuthor

    Problem

    The release APK published on Google Play has DEX code optimization disabled. R8 code shrinking is not configured in owncloudApp/build.gradle, so the release build type defaults to minifyEnabled false. Google Play Console flags this in Android Vitals and requires it to be fixed by February 2027.


    Desired behavior

    Release builds of the ownCloud Android app are processed by R8 with code shrinking and optimization enabled. The resulting APK passes Google Play's DEX optimization quality check, is smaller in size, and continues to function correctly.


    User stories

    • As a developer, I want release builds to apply R8 code shrinking so the app passes Google Play's DEX optimization threshold.
    • As a developer, I want existing functionality to work correctly in release builds after R8 optimization is enabled.
    • As a developer, I want debug builds to remain unaffected so the daily development workflow is not disrupted.

    Constraints

    • No new runtime dependencies may be introduced.
    • Library modules (owncloudData, owncloudDomain, owncloudComLibrary) must keep minifyEnabled false; only the application module is changed.
    • The debug build type must remain unminified.

    Acceptance criteria

    • minifyEnabled true is set in the release build type of owncloudApp/build.gradle.
    • proguardFiles references getDefaultProguardFile('proguard-android-optimize.txt') and a new owncloudApp/proguard-rules.pro.
    • owncloudApp/proguard-rules.pro contains keep rules covering all CoroutineWorker subclasses in com.owncloud.android.workers, Moshi @JsonClass-annotated models in owncloudComLibrary, and any classes loaded by name via reflection or the Android
      framework.
    • ./gradlew assembleOriginalRelease produces a valid, installable APK without errors.
    • A manual smoke test of the release build confirms that login, file listing, upload, download, and background sync (automatic uploads) work correctly.

    Out of scope

    • Enabling shrinkResources in the release build type.
    • Enabling minification in library modules or the debug build type.
    • Deleting or modifying any existing files unrelated to this change.
    • Integrating a crash-reporting SDK or automating deobfuscation beyond the Play Console mapping upload.
    • Addressing other Google Play Vitals signals.

    Assumptions

    • AGP 9.x uses R8 by default; no explicit R8 toolchain configuration is needed beyond minifyEnabled true.
    • Moshi classes in owncloudComLibrary use KSP code generation (@JsonClass(generateAdapter = true)) and Moshi.Builder().build() without KotlinJsonAdapterFactory. Moshi finds generated adapters at runtime via Class.forName() using the adapter class name
      derived from the model class name; keep rules are therefore required to prevent R8 from renaming those classes.
    • CoroutineWorker subclasses are instantiated by WorkManager via reflection using the class name registered in WorkRequest; they require explicit keep rules.
    • Room generates its implementation at compile time; @entity and @dao keep rules are already provided by Room's own consumer ProGuard rules, but this must be verified by inspecting configuration.txt after the first successful build.
    • Koin resolves dependencies via reified type parameters at runtime; no additional keep rules are required for Koin wiring itself.
    • The dexopener library in androidTestImplementation affects instrumented test builds only and is not impacted by this change.

    Implementation notes

    • R8 applies rules cumulatively: the AGP default file (proguard-android-optimize.txt) + proguard-rules.pro + consumer rules from each library module. Check the merged rules at owncloudApp/build/outputs/mapping/originalRelease/configuration.txt after the
      first successful build to confirm coverage and spot unexpected gaps.
    • The @keep annotation can be applied directly to any class or member that must survive shrinking — prefer it over ProGuard rules for app-level classes where the source is owned.
    • Build the release APK, install it on a device or emulator, and exercise the workers (trigger an automatic upload) before opening the PR to catch missing keep rules early. Missing rules surface as ClassNotFoundException or Moshi deserialization errors at
      runtime, not at build time.
    • The -dontobfuscate rule must not be added; obfuscation reduces APK size and raises the bar for reverse engineering.
  2. added this to the 5.0 - Current milestone on Oct 22, 2026
  3. linked a pull request that will close this issuebuild: DEX code optimization #5032on Oct 22, 2026
  4. changed the title [-][BUG] DEX code optimisation is below Google threshold[/-] [+][TECHNICAL] DEX code optimisation is below Google threshold[/+] on Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions