Sanniv Khare 5 min read

AGP 9.6 alpha06 fixes prefab after clean: tested on React Native

AGP 9.6 alpha06 fixes prefab after clean: tested on React Native

The short version: if you try the Android Gradle Plugin 9.6 canaries on a React Native app that uses Reanimated, skip 9.6.0-alpha05. On our M1 lab Mac a fresh React Native 0.88.1 app with react-native-reanimated 4.7.1 and react-native-worklets 0.13.1 built once on AGP 9.6.0-alpha05, then failed the second ./gradlew clean assembleDebug because Reanimated’s prefab package was never rebuilt. On 9.6.0-alpha06, which ships with Android Studio Stingray 1 Canary 3 (24 Nov 2026), the same two builds both succeed.

Why we did this: our React Native banking and TV apps (and BMDB.fun on Android TV) all pull native libraries through prefab, and we try each AGP canary on a sample app before it reaches a real project. This one matches a fix in the Canary 3 notes, so we wanted to see the failure and the fix with our own builds.

Four clean builds on one Mac: alpha05 fails the second time, alpha06 passes twice

Real results from our M1 lab Mac. One Mac, one run each: these are not benchmarks.

The bug, in Google’s words

The Android Studio Stingray 1 Canary 3 release post lists issue 551999754 among its AGP fixes: PrefabPackageConfigurationTask “declares an @OutputFile it never writes; after gradlew clean prefab consumers silently lose the library and fail to link”. Canary 3 ships AGP 9.6.0-alpha06. Canary 2 (20 Nov) shipped alpha05, and Canary 1 shipped alpha04; we covered that one in Android Studio Stingray Canary 1: the AGP 9.6 build fixes.

Prefab is how Android libraries publish C++ headers and .so files to each other. In a React Native app, react-native-worklets publishes a prefab package and react-native-reanimated both consumes it and publishes its own, which the app’s CMake build then links. A library that publishes prefab gets a prefab<Variant>ConfigurePackage task from AGP. If Gradle thinks that task is up to date when its output is gone, the package directory never comes back.

What we built

Version
App fresh React Native 0.88.1 app (community CLI 20.2.0)
Native libraries react-native-worklets 0.13.1, react-native-reanimated 4.7.1
Gradle 9.8.2 (the minimum and default for AGP 9.6.0 in the AGP 9.6 release notes)
Kotlin Gradle plugin 2.4.10 (AGP 9.6 needs 2.2.10 or newer)
JDK Zulu 17.0.21
Mac Apple M1, 16 GB, macOS 15.7.3

Each build ran this command, twice per AGP version:

./gradlew --no-configuration-cache clean assembleDebug \
  -PreactNativeArchitectures=arm64-v8a

The only change to the template was the AGP version in android/build.gradle:

dependencies {
    classpath("com.android.tools.build:gradle:9.6.0-alpha05")
    classpath("com.facebook.react:react-native-gradle-plugin")
    classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:2.4.10")
}

A detour you will hit first: Kotlin 2.4 inside Gradle 9.8

Our first attempt never reached AGP. Gradle 9.8.2 bundles Kotlin 2.4.10, and React Native 0.88.1’s own Gradle plugin (an included build under node_modules/@react-native/gradle-plugin) pins Kotlin 2.2.0 in its gradle/libs.versions.toml. Compiling its settings plugin failed with:

e: Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin.
The actual metadata version is 2.4.0, but the compiler version 2.2.0
can read versions up to 2.3.0.

For this test we raised that one line to kotlin = "2.4.10". That is a canary experiment, not something to ship: if you try AGP 9.6 previews on React Native 0.88, expect to patch the plugin’s Kotlin version (for example with patch-package) until a React Native release moves it.

alpha05: the second clean build fails

The first clean assembleDebug on alpha05 passed in 5 min 28 s (that run also downloaded the alpha05 artifacts). The second one, with nothing changed, failed in 20 s:

alpha05: Reanimated's prefabDebugConfigurePackage is UP-TO-DATE after clean, and CMake configure fails

The relevant lines of the second build, paths shortened.

The log shows the mechanism. clean ran in both libraries. Then worklets ran its prefabDebugConfigurePackage, but Reanimated’s was reported UP-TO-DATE, so nothing recreated android/build/intermediates/prefab_package/debug/prefab. When the app’s configureCMakeDebug[arm64-v8a] called the prefab CLI with that directory, it stopped with “is not readable”.

Why worklets survived and Reanimated did not is visible in their sources. react-native-worklets 0.13.1 ships a fix-prefab.gradle.kts that, among other things, does this to its own configure tasks:

tasks.configureEach {
    val prefabConfigurePattern = Regex("^prefab(.+)ConfigurePackage$")
    val matchResult = prefabConfigurePattern.matchEntire(name)
    if (matchResult != null) {
        val variantName = matchResult.groupValues[1]
        outputs.upToDateWhen { false }
        dependsOn("externalNativeBuild$variantName")
    }
}

outputs.upToDateWhen { false } forces the task to run every time, which hides exactly this kind of bad up-to-date check. react-native-reanimated 4.7.1 publishes prefab without that script, so it is the library that lost its package.

alpha06: two clean builds, both pass

We changed only 9.6.0-alpha05 to 9.6.0-alpha06 and ran the same command twice more. The first build passed in 3 min 51 s, the second in 1 min 1 s, and in both logs Reanimated’s prefabDebugConfigurePackage ran instead of being skipped. The arm64-v8a debug APK came out at 54,960,304 bytes.

The second alpha06 build was faster, most likely because Gradle reuses its transform caches and the downloaded dependencies; clean only removes the project build folders. Treat the times as one run on one Mac.

What to do on your project

  1. On AGP 9.6 previews, use 9.6.0-alpha06 or newer. Android Studio Stingray 1 Canary 3 bundles it; for command-line builds set the version in android/build.gradle as above.
  2. Stay on Gradle 9.8.2 or newer for AGP 9.6, and expect React Native 0.88’s Gradle plugin to need its Kotlin version raised to match Gradle’s bundled Kotlin.
  3. If you are stuck on alpha05, the worklets pattern is the workaround: make the prefab configure tasks of the publishing libraries never up to date. As a starting point to adapt (we did not ship this, since alpha06 removes the need), in the root android/build.gradle:
subprojects {
    tasks.configureEach { task ->
        if (task.name ==~ /^prefab.+ConfigurePackage$/) {
            task.outputs.upToDateWhen { false }
        }
    }
}
  1. Run clean twice in CI when you test a new AGP. A single clean build on a fresh checkout passed on alpha05; only the second one showed the bug.

The other fixes in Canary 3

The same post lists two more AGP fixes worth knowing if you test with R8 or lint:

  • Issue 586849342: in a com.android.test module, -applymapping did not rewrite references to tested-app classes reached through testFixtures().
  • Issue 585534512: K2 lint reported a false “Unexpected constant” from SwitchIntDef for @IntDef constants declared in the annotation class’s companion object when the annotation comes from a binary dependency.

Neither touched our sample app.

Made by the team behind this post

Apps from our studio

  • Goes with this post

    BMDB.fun

    Your Bollywood world at a glance, with links straight to the OTT app that streams each film.

    Android TV · Web · Mobile

    Get
  • Nix

    The Mac uninstaller that finds what the Trash leaves behind: caches, logs, derived data and saved states.

    macOS

    Get
  • Cardigami

    Pop-up greeting cards that rise out of the fold on iPhone Duo.

    iPhone · App Store

    Get
  • OneClick QuitAll

    Quit every running app in one click. See memory and CPU first.

    macOS · Mac App Store

    Get

Need this built? Let’s talk.

We build and run apps for Mac, TV, mobile and the web, and write about what we learn.