From 1a51b42aa582d381c15860ed48f0742b61a16afc Mon Sep 17 00:00:00 2001 From: Gabriel Donadel Dall'Agnol Date: Fri, 4 Sep 2026 08:37:20 -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. --- .../react-native-executorch-webrtc/android/build.gradle | 8 +++++++- packages/react-native-executorch/android/build.gradle | 9 ++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/react-native-executorch-webrtc/android/build.gradle b/packages/react-native-executorch-webrtc/android/build.gradle index 919f9d2666..8a65360122 100644 --- a/packages/react-native-executorch-webrtc/android/build.gradle +++ b/packages/react-native-executorch-webrtc/android/build.gradle @@ -13,7 +13,13 @@ buildscript { } 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' +} android { namespace 'com.executorch.webrtc' diff --git a/packages/react-native-executorch/android/build.gradle b/packages/react-native-executorch/android/build.gradle index be4a2f5373..f36b80e302 100644 --- a/packages/react-native-executorch/android/build.gradle +++ b/packages/react-native-executorch/android/build.gradle @@ -34,7 +34,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 plugin: "com.facebook.react"