Skip to content

Commit 4fdef5d

Browse files
ADFA-6180 | NDK template: build under AGP 9's built-in Kotlin (#107)
fix(ADFA-6180): build NDK template projects under AGP 9's built-in Kotlin AGP 9 compiles Kotlin itself and puts the Kotlin Gradle plugin on the classpath, so the template's kotlin("android") plugin request failed with "already on the classpath with an unknown version". Follow the core templates: pin KGP on the root buildscript classpath, drop the plugin, force kotlin-stdlib to KOTLIN_VERSION instead of 1.9.22, and move jvmTarget from the removed kotlinOptions to kotlin.compilerOptions. Bump NDK-Installer to 1.1.1. Co-authored-by: Daniel Alome <astrocoder007@gmail.com>
1 parent 31191a8 commit 4fdef5d

3 files changed

Lines changed: 20 additions & 11 deletions

File tree

‎plugins/NDK-Installer/build.gradle.kts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ android {
2323
applicationId = "org.appdevforall.ndkinstaller"
2424
minSdk = 26
2525
targetSdk = 36
26-
versionCode = 2
27-
versionName = "1.1.0"
26+
versionCode = 3
27+
versionName = "1.1.1"
2828
}
2929

3030
buildTypes {

‎plugins/NDK-Installer/src/main/assets/templates/ndk/app/build.gradle.kts.peb‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ import java.io.FileInputStream
33

44
plugins {
55
id("com.android.application") version "${{AGP_VERSION}}"
6-
${% if LANGUAGE == 'kotlin' %}
7-
kotlin("android") version "${{KOTLIN_VERSION}}"
8-
${% endif %}
96
}
107

118
val keystorePropsFile = rootProject.file("release.properties")
@@ -136,10 +133,10 @@ android {
136133

137134
configurations.all {
138135
resolutionStrategy {
139-
// Force the use of Kotlin stdlib 1.9.22 for all modules
140-
force("org.jetbrains.kotlin:kotlin-stdlib:1.9.22")
141-
force("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.22")
142-
force("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.22")
136+
// Force the use of Kotlin stdlib for all modules
137+
force("org.jetbrains.kotlin:kotlin-stdlib:${{KOTLIN_VERSION}}")
138+
force("org.jetbrains.kotlin:kotlin-stdlib-jdk7:${{KOTLIN_VERSION}}")
139+
force("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${{KOTLIN_VERSION}}")
143140

144141
// Force specific AndroidX versions to avoid conflicts
145142
force("androidx.collection:collection:1.4.2")
@@ -157,9 +154,11 @@ tasks.withType<JavaCompile> {
157154

158155

159156
${% if LANGUAGE == 'kotlin' %}
160-
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
161-
kotlinOptions.jvmTarget = "${{JAVA_TARGET}}"
157+
kotlin {
158+
compilerOptions {
159+
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.fromTarget("${{JAVA_TARGET}}"))
162160
}
161+
}
163162
${% endif %}
164163

165164
dependencies {

‎plugins/NDK-Installer/src/main/assets/templates/ndk/build.gradle.kts.peb‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
2+
buildscript {
3+
repositories {
4+
google()
5+
mavenCentral()
6+
}
7+
dependencies {
8+
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${{KOTLIN_VERSION}}")
9+
}
10+
}
11+
212
plugins {
313
id("com.android.application") apply false version "${{AGP_VERSION}}"
414
id("com.android.library") apply false version "${{AGP_VERSION}}"

0 commit comments

Comments
 (0)