Skip to content

Commit 40c0c32

Browse files
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.
1 parent 8679806 commit 40c0c32

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎android/build.gradle‎

100755100644
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ def safeExtGet(prop, fallback) {
1919

2020
apply plugin: "com.android.library"
2121
apply plugin: "com.facebook.react"
22-
apply plugin: "kotlin-android"
22+
// AGP 9 ships built-in Kotlin support and registers the `kotlin` extension
23+
// itself. Applying the Kotlin plugin on top of it fails configuration with
24+
// "Cannot add extension with name 'kotlin'". Only apply it when nothing has
25+
// registered that extension yet.
26+
if (project.extensions.findByName('kotlin') == null) {
27+
apply plugin: "kotlin-android"
28+
}
2329

2430
android {
2531
namespace "com.xmartlabs.line"

0 commit comments

Comments
 (0)