From f2eb2f4454ffb3c9a2cbfa6e3556dac291cacdcd Mon Sep 17 00:00:00 2001 From: Gabriel Donadel Dall'Agnol Date: Sat, 5 Sep 2026 09:08:57 -0700 Subject: [PATCH 1/3] fix(android): skip explicit Kotlin plugin when AGP registers the kotlin extension AGP 9 ships built-in Kotlin support and registers the kotlin extension itself. Applying the Kotlin plugin again fails configuration with "Cannot add extension with name 'kotlin'". Check for the extension directly, which needs no AGP version table and covers AGP 10, where the android.builtInKotlin opt-out is removed. --- android/build.gradle | 9 ++++++++- rive-debug-utils/android/build.gradle | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 6c88ff8b..503e5903 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -21,7 +21,14 @@ def reactNativeArchitectures() { } apply plugin: "com.android.library" -apply plugin: "kotlin-android" +// AGP 9 ships built-in Kotlin support and registers the `kotlin` extension +// itself. Applying the Kotlin plugin on top of it fails configuration with +// "Cannot add extension with name 'kotlin'". Only apply it when nothing has +// registered that extension yet. +if (project.extensions.findByName('kotlin') == null) { + apply plugin: "kotlin-android" +} + apply from: '../nitrogen/generated/android/rive+autolinking.gradle' apply plugin: "com.facebook.react" diff --git a/rive-debug-utils/android/build.gradle b/rive-debug-utils/android/build.gradle index 7ec982aa..403b0a0f 100644 --- a/rive-debug-utils/android/build.gradle +++ b/rive-debug-utils/android/build.gradle @@ -21,7 +21,14 @@ def reactNativeArchitectures() { } apply plugin: "com.android.library" -apply plugin: "kotlin-android" +// AGP 9 ships built-in Kotlin support and registers the `kotlin` extension +// itself. Applying the Kotlin plugin on top of it fails configuration with +// "Cannot add extension with name 'kotlin'". Only apply it when nothing has +// registered that extension yet. +if (project.extensions.findByName('kotlin') == null) { + apply plugin: "kotlin-android" +} + apply from: '../nitrogen/generated/android/RiveDebugUtils+autolinking.gradle' android { From 4679f74838feb8de84c5dc5c6cb4cbbd1e71a1d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikl=C3=B3s=20Fazekas?= Date: Sun, 11 Oct 2026 11:41:00 +0200 Subject: [PATCH 2/3] chore: shorten AGP 9 Kotlin guard comment --- android/build.gradle | 6 +----- rive-debug-utils/android/build.gradle | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 503e5903..857635d4 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -21,14 +21,10 @@ def reactNativeArchitectures() { } apply plugin: "com.android.library" -// AGP 9 ships built-in Kotlin support and registers the `kotlin` extension -// itself. Applying the Kotlin plugin on top of it fails configuration with -// "Cannot add extension with name 'kotlin'". Only apply it when nothing has -// registered that extension yet. +// AGP 9's built-in Kotlin already registers the `kotlin` extension; applying kotlin-android again fails. if (project.extensions.findByName('kotlin') == null) { apply plugin: "kotlin-android" } - apply from: '../nitrogen/generated/android/rive+autolinking.gradle' apply plugin: "com.facebook.react" diff --git a/rive-debug-utils/android/build.gradle b/rive-debug-utils/android/build.gradle index 403b0a0f..baa6bf47 100644 --- a/rive-debug-utils/android/build.gradle +++ b/rive-debug-utils/android/build.gradle @@ -21,14 +21,10 @@ def reactNativeArchitectures() { } apply plugin: "com.android.library" -// AGP 9 ships built-in Kotlin support and registers the `kotlin` extension -// itself. Applying the Kotlin plugin on top of it fails configuration with -// "Cannot add extension with name 'kotlin'". Only apply it when nothing has -// registered that extension yet. +// AGP 9's built-in Kotlin already registers the `kotlin` extension; applying kotlin-android again fails. if (project.extensions.findByName('kotlin') == null) { apply plugin: "kotlin-android" } - apply from: '../nitrogen/generated/android/RiveDebugUtils+autolinking.gradle' android { From cac816515236052c71f2900811a2da2ee8e764ba Mon Sep 17 00:00:00 2001 From: Gabriel Donadel Dall'Agnol Date: Sun, 11 Oct 2026 07:32:29 -0700 Subject: [PATCH 3/3] fix(android): register Kotlin source dirs for AGP 9 built-in Kotlin Built-in Kotlin only compiles kotlin.srcDirs, so the Kotlin sources that were reachable only through java.srcDirs (src/new/java or src/legacy/java, and the Nitrogen-generated android/kotlin dir added by rive+autolinking.gradle) failed with unresolved references. --- android/build.gradle | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 857635d4..07b7c67e 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -125,13 +125,15 @@ android { sourceSets { main { + def riveSrcDir = useLegacy ? "src/legacy/java" : "src/new/java" java.srcDirs += ["generated/java", - "generated/jni"] - if (useLegacy) { - java.srcDirs += ["src/legacy/java"] - } else { - java.srcDirs += ["src/new/java"] - } + "generated/jni", + riveSrcDir] + // AGP 9 built-in Kotlin only compiles kotlin.srcDirs (plus the default + // src/main/java), so register the Kotlin dirs that are only on java.srcDirs, + // including the Nitrogen-generated ones added by rive+autolinking.gradle. + kotlin.srcDirs += [riveSrcDir, + "${project.projectDir}/../nitrogen/generated/android/kotlin"] } } }