diff --git a/packages/react-native-nitro-fetch/android/build.gradle b/packages/react-native-nitro-fetch/android/build.gradle index 847ad9b4..0066c74a 100644 --- a/packages/react-native-nitro-fetch/android/build.gradle +++ b/packages/react-native-nitro-fetch/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/nitrofetch+autolinking.gradle' // Do not apply React Gradle plugin in library to avoid RN codegen duplicating app classes diff --git a/packages/react-native-nitro-text-decoder/android/build.gradle b/packages/react-native-nitro-text-decoder/android/build.gradle index a3742f10..4bd974ad 100644 --- a/packages/react-native-nitro-text-decoder/android/build.gradle +++ b/packages/react-native-nitro-text-decoder/android/build.gradle @@ -19,7 +19,14 @@ def isNewArchitectureEnabled() { } 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 from: '../nitrogen/generated/android/NitroTextDecoder+autolinking.gradle' apply from: "./fix-prefab.gradle" diff --git a/packages/react-native-nitro-websockets/android/build.gradle b/packages/react-native-nitro-websockets/android/build.gradle index 2d3e987e..059cc28f 100644 --- a/packages/react-native-nitro-websockets/android/build.gradle +++ b/packages/react-native-nitro-websockets/android/build.gradle @@ -19,7 +19,14 @@ def isNewArchitectureEnabled() { } 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 from: '../nitrogen/generated/android/NitroFetchWebsockets+autolinking.gradle' apply from: "./fix-prefab.gradle"