From ae9fea4925f940656ced4642dcbfc022396eba38 Mon Sep 17 00:00:00 2001 From: Gabriel Donadel Dall'Agnol Date: Fri, 4 Sep 2026 08:36:59 -0700 Subject: [PATCH] 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. --- packages/react-native-audio-api/android/build.gradle | 8 +++++++- packages/react-native-audio-worklets/android/build.gradle | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/react-native-audio-api/android/build.gradle b/packages/react-native-audio-api/android/build.gradle index 8305f9c7d..8941bf813 100644 --- a/packages/react-native-audio-api/android/build.gradle +++ b/packages/react-native-audio-api/android/build.gradle @@ -31,7 +31,13 @@ def isStaticExternalLibsDisabled() { } apply plugin: "com.android.library" -apply plugin: 'org.jetbrains.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: 'org.jetbrains.kotlin.android' +} if (isNewArchitectureEnabled()) { apply plugin: "com.facebook.react" diff --git a/packages/react-native-audio-worklets/android/build.gradle b/packages/react-native-audio-worklets/android/build.gradle index cf04cc9b6..7036fbd8f 100644 --- a/packages/react-native-audio-worklets/android/build.gradle +++ b/packages/react-native-audio-worklets/android/build.gradle @@ -67,7 +67,13 @@ def supportsNamespace() { } apply plugin: "com.android.library" -apply plugin: "org.jetbrains.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: "org.jetbrains.kotlin.android" +} apply plugin: "com.facebook.react"