From 8cbf392177454ef948b487e1a1983e3ab9b5b054 Mon Sep 17 00:00:00 2001 From: Evsyukov Denis Date: Mon, 2 Nov 2026 12:12:27 +0300 Subject: [PATCH 1/2] build: upgrade to AGP 9.5.0 and Gradle 9.8.1 AGP 9 brings built-in Kotlin, so the Kotlin Android plugin goes away, and drops kapt support, so Room's compiler moves to KSP. AGP 9 rejects Provider source directories; the generated test TLS directories are added by path. --- app/build.gradle.kts | 11 ++++++----- build.gradle.kts | 5 ++--- gradle/wrapper/gradle-wrapper.properties | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 3d331ce..26ffd82 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,8 +1,7 @@ plugins { id("com.android.application") - id("org.jetbrains.kotlin.android") id("org.jetbrains.kotlin.plugin.compose") - id("org.jetbrains.kotlin.kapt") + id("com.google.devtools.ksp") } val releaseKeystore = providers.environmentVariable("SHAREDING_RELEASE_KEYSTORE").orNull @@ -52,8 +51,10 @@ android { namespace = "org.evsyukov.shareding" compileSdk = 36 - sourceSets.getByName("debug").res.srcDir(testTlsRoot.map { it.dir("debug/res") }) - sourceSets.getByName("androidTest").assets.srcDir(testTlsRoot.map { it.dir("androidTest/assets") }) + // AGP 9 rejects Provider source directories; the tasks above are wired in by name. + sourceSets.getByName("debug").res.directories.add(testTlsRoot.get().dir("debug/res").asFile.path) + sourceSets.getByName("androidTest").assets.directories + .add(testTlsRoot.get().dir("androidTest/assets").asFile.path) defaultConfig { applicationId = "org.evsyukov.shareding" @@ -131,7 +132,7 @@ dependencies { implementation("androidx.room:room-runtime:2.8.5") implementation("androidx.room:room-ktx:2.8.5") - kapt("androidx.room:room-compiler:2.8.5") + ksp("androidx.room:room-compiler:2.8.5") implementation("androidx.work:work-runtime-ktx:2.12.0") implementation("com.google.code.gson:gson:2.13.2") diff --git a/build.gradle.kts b/build.gradle.kts index e6bb059..5009af3 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,5 @@ plugins { - id("com.android.application") version "8.13.2" apply false - id("org.jetbrains.kotlin.android") version "2.3.21" apply false + id("com.android.application") version "9.5.0" apply false id("org.jetbrains.kotlin.plugin.compose") version "2.3.21" apply false - id("org.jetbrains.kotlin.kapt") version "2.3.21" apply false + id("com.google.devtools.ksp") version "2.3.12" apply false } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index c99f974..d6ce2e6 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip -distributionSha256Sum=20f1b1176237254a6fc204d8434196fa11a4cfb387567519c61556e8710aed78 +distributionSha256Sum=dce76f55f8e251a3a1f130eb120f30b3d271de2b76c9b0729d316b5a1b6dc01f +distributionUrl=https\://services.gradle.org/distributions/gradle-9.8.1-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME From f2841335fa862c1fd470a02492605ac3cd9bdd0f Mon Sep 17 00:00:00 2001 From: Evsyukov Denis Date: Mon, 2 Nov 2026 12:17:24 +0300 Subject: [PATCH 2/2] docs: record the R8 and AGP 9 measurements --- docs/research/r8-agp9.md | 41 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 docs/research/r8-agp9.md diff --git a/docs/research/r8-agp9.md b/docs/research/r8-agp9.md new file mode 100644 index 0000000..d871852 --- /dev/null +++ b/docs/research/r8-agp9.md @@ -0,0 +1,41 @@ +# R8 optimization and the AGP 9 upgrade + +Measured on 2026-11-02 for [#51](https://github.com/juev/shareding/issues/51). + +## Why + +Google Play Console flagged release 28 (0.3.1) under "Improve your app's memory and performance with R8 optimization": + +- Optimized resource shrinking isn't enabled. +- Upgrade your Android Gradle plugin to version 9.0 or higher. + +The same release also got "Improve your app's performance with bitmap downsampling" for `o3.a.a` and `o3.c.h`. The R8 mapping in the bundle resolves both to `androidx.core` (`ShortcutInfoCompat` and `ShortcutManagerCompat`), which ShareDing uses to publish the Direct Share target. ShareDing does not call `BitmapFactory`, and the shortcut icon comes from a resource, so that item was left alone. + +## Builds compared + +Unsigned release builds of 0.3.1 (versionCode 28), same sources: + +| Build | APK | dex | resources.arsc | Files in `res/` | +|---|---|---|---|---| +| AGP 8.13.2, Gradle 8.13 | 4 267 600 B | 2 915 548 | 159 052 | 37 | +| AGP 8.13.2 + `android.r8.optimizedResourceShrinking=true` | 4 192 908 (−1.8 %) | 2 914 660 | 96 908 | 5 | +| AGP 9.5.0, Gradle 9.8.1 | 4 060 496 (−4.9 %) | 2 780 548 (−4.6 %) | 95 936 | 5 | + +AGP 9 applies optimized resource shrinking by default: its `resources.arsc` matches the flagged build without the flag. The dex sizes include the 1 396-byte `classes2.dex` with desugared library classes that the AGP 9 build adds. + +Cold start (`am start -W`, six runs per build, twice) and total PSS after launch were measured on an API 36 emulator. Start times varied more between runs than between builds, and PSS stayed at about 28 MB for all three. The gain is in download and install size, not in a measurable runtime difference. + +## Checks + +On the AGP 9 build: + +- `assembleDebug lintDebug testDebugUnitTest connectedDebugAndroidTest` pass: 52 unit tests and 75 instrumented tests on API 36. +- The release APK was signed with a debug key, installed on the emulator, and walked through: Add, Settings with the About icon, and Share from another app. The shared link reached the queue and no crash was logged. +- Two clean release builds produced byte-identical APKs. + +## Upgrade notes + +- AGP 9 has built-in Kotlin, so the `org.jetbrains.kotlin.android` plugin is removed. +- AGP 9 no longer supports kapt; Room's compiler runs on KSP. +- AGP 9 rejects `Provider` source directories (`You cannot add Provider instances to the Android SourceSet API`). The generated test TLS directories are added by path, and the generating tasks stay wired in by name. +- Gradle 9.8.1 reports one deprecation, `Configuration.setVisible(boolean)`, from a plugin rather than from this build's scripts. It is scheduled for removal in Gradle 11.