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"