File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ " @callstack/repack " : patch
3+ ---
4+
5+ Fix Android configuration on AGP 9, where built-in Kotlin support registers the
6+ ` kotlin ` extension itself and the explicit ` kotlin-android ` apply failed with
7+ "Cannot add extension with name 'kotlin'". The plugin - and the ` kotlinOptions `
8+ block it contributes - is now applied only when nothing has registered that
9+ extension, leaving AGP 8 and ` android.builtInKotlin=false ` projects unchanged.
Original file line number Diff line number Diff line change @@ -31,7 +31,14 @@ def isNewArchitectureEnabled() {
3131}
3232
3333apply plugin : ' com.android.library'
34- apply plugin : ' kotlin-android'
34+ // AGP 9 ships built-in Kotlin support and registers the `kotlin` extension
35+ // itself. Applying the Kotlin plugin on top of it fails configuration with
36+ // "Cannot add extension with name 'kotlin'". Only apply it when nothing has
37+ // registered that extension yet.
38+ def appliesKotlinPlugin = project. extensions. findByName(' kotlin' ) == null
39+ if (appliesKotlinPlugin) {
40+ apply plugin : ' kotlin-android'
41+ }
3542
3643if (isNewArchitectureEnabled()) {
3744 apply plugin : " com.facebook.react"
@@ -130,11 +137,13 @@ android {
130137 }
131138 }
132139
133- kotlinOptions {
134- if (REACT_NATIVE_MINOR_VERSION < 69 ) {
135- jvmTarget = JavaVersion . VERSION_1_8
136- } else if (REACT_NATIVE_MINOR_VERSION < 73 ) {
137- jvmTarget = JavaVersion . VERSION_11
140+ if (appliesKotlinPlugin) {
141+ kotlinOptions {
142+ if (REACT_NATIVE_MINOR_VERSION < 69 ) {
143+ jvmTarget = JavaVersion . VERSION_1_8
144+ } else if (REACT_NATIVE_MINOR_VERSION < 73 ) {
145+ jvmTarget = JavaVersion . VERSION_11
146+ }
138147 }
139148 }
140149
You can’t perform that action at this time.
0 commit comments