Skip to content

Commit 176c5ec

Browse files
authored
fix(android): only apply Kotlin plugin if not using built-in (#2830)
1 parent 9933a50 commit 176c5ec

2 files changed

Lines changed: 24 additions & 6 deletions

File tree

packages/app/android/app/build.gradle

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,15 @@ buildscript {
77

88
plugins {
99
id("com.android.application")
10-
id("org.jetbrains.kotlin.android")
10+
id("org.jetbrains.kotlin.android") apply false
11+
}
12+
13+
// Only apply Kotlin plugin if `android.builtInKotlin=false`
14+
// https://developer.android.com/build/migrate-to-built-in-kotlin#enable-built-in-kotlin
15+
def useBuiltInKotlin = toVersionNumber(gradle.gradleVersion) >= v(9, 4, 0) &&
16+
project.findProperty("android.builtInKotlin") != false
17+
if (!useBuiltInKotlin) {
18+
apply(plugin: "org.jetbrains.kotlin.android")
1119
}
1220

1321
// `react-native run-android` is hard-coded to look for the output APK at a very
@@ -76,8 +84,10 @@ android {
7684
prefab = true
7785
}
7886

79-
kotlinOptions {
80-
allWarningsAsErrors = true
87+
if (!useBuiltInKotlin) {
88+
kotlinOptions {
89+
allWarningsAsErrors = true
90+
}
8191
}
8292

8393
defaultConfig {
@@ -205,6 +215,14 @@ android {
205215
}
206216
}
207217

218+
if (useBuiltInKotlin) {
219+
kotlin {
220+
compilerOptions {
221+
allWarningsAsErrors = true
222+
}
223+
}
224+
}
225+
208226
dependencies {
209227
implementation project(":support")
210228

yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15227,9 +15227,9 @@ __metadata:
1522715227
linkType: hard
1522815228

1522915229
"undici@npm:^6.19.5, undici@npm:^6.21.3":
15230-
version: 6.24.1
15231-
resolution: "undici@npm:6.24.1"
15232-
checksum: 10c0/53fdbaa357139a2c12deed34f67d67fc6ad269630ba85a1507e7717f53ad2d3a02c95fbd17d3ab321e34c60b6f0a716cdc2f7e2eca1e07178702dc89cc3a73c4
15230+
version: 6.27.0
15231+
resolution: "undici@npm:6.27.0"
15232+
checksum: 10c0/f88c3dae3957dbf9d93cb481440aced317bd3c4941b5914fea5efba516d51138988cdb5c76006f0bb1337e41d56c3443351055d492e73af2428521c37ba2a76f
1523315233
languageName: node
1523415234
linkType: hard
1523515235

0 commit comments

Comments
 (0)