Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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")
Expand Down
5 changes: 2 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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
}
41 changes: 41 additions & 0 deletions docs/research/r8-agp9.md
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Loading