Skip to content

Commit 468cb01

Browse files
Migrate to new Android Gradle Plugin DSL
This commit updates the build scripts to align with the modern Android Gradle Plugin (AGP) DSL and removes several deprecated properties and plugins. Key changes include: * **`app/build.gradle.kts`:** * Migrated from the `android {}` block to the new `extensions.configure<ApplicationExtension>("android") {}` block. * Replaced the `compileSdk { version = ... }` method with the direct `compileSdk = ...` property assignment. * Removed the explicit `kotlin {}` block for JVM toolchain configuration, as it's now handled by the `compileOptions` within the `android` block. * Eliminated the now-deprecated `applicationVariants.all` block for renaming APK outputs. * Enabled `resValues` directly within the `buildFeatures` block. * **`gradle.properties`:** * Removed several obsolete or now-default AGP flags, such as `android.nonFinalResIds`, `android.newDsl`, and `android.r8.optimizedResourceShrinking`. * **Plugin Configuration:** * Removed the `kotlin-android` plugin from `build.gradle.kts` and `gradle/libs.versions.toml`, as it is no longer required with recent AGP versions.
1 parent 2bcfc56 commit 468cb01

4 files changed

Lines changed: 7 additions & 43 deletions

File tree

app/build.gradle.kts

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
import com.android.build.api.dsl.ApplicationExtension
2+
13
plugins {
24
alias(libs.plugins.android.application)
3-
alias(libs.plugins.kotlin.android)
45
alias(libs.plugins.kotlin.compose)
56
alias(libs.plugins.ksp)
67
}
@@ -26,12 +27,11 @@ val baseVersionCode =
2627
// Android configuration
2728
// =========================
2829

29-
android {
30+
extensions.configure<ApplicationExtension>("android") {
31+
3032
namespace = "com.github.codeworkscreativehub.mlauncher"
3133

32-
compileSdk {
33-
version = release(36)
34-
}
34+
compileSdk = 36
3535

3636
defaultConfig {
3737
minSdk = 28
@@ -93,7 +93,6 @@ android {
9393
isMinifyEnabled = false
9494
isShrinkResources = false
9595
applicationIdSuffix = ".debug"
96-
9796
signingConfig = signingConfigs["release"]
9897

9998
resValue("string", "app_version", baseVersionCode.toString())
@@ -117,22 +116,11 @@ android {
117116
}
118117
}
119118

120-
applicationVariants.all {
121-
val flavorName = this.flavorName
122-
123-
outputs.all {
124-
val output =
125-
this as com.android.build.gradle.internal.api.BaseVariantOutputImpl
126-
127-
output.outputFileName =
128-
"app_${flavorName}_release.apk"
129-
}
130-
}
131-
132119
buildFeatures {
133120
compose = true
134121
viewBinding = true
135122
buildConfig = true
123+
resValues = true
136124
}
137125

138126
compileOptions {
@@ -151,26 +139,11 @@ android {
151139
}
152140

153141
dependenciesInfo {
154-
// Disables dependency metadata when building APKs (for IzzyOnDroid/F-Droid)
155142
includeInApk = false
156-
// Disables dependency metadata when building Android App Bundles (for Google Play)
157143
includeInBundle = false
158144
}
159145
}
160146

161-
// =========================
162-
// Kotlin
163-
// =========================
164-
165-
kotlin {
166-
jvmToolchain(17)
167-
168-
compilerOptions {
169-
jvmTarget.set(
170-
org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17
171-
)
172-
}
173-
}
174147

175148
// =========================
176149
// KSP

build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
plugins {
22
alias(libs.plugins.android.application) apply false
33
alias(libs.plugins.android.library) apply false
4-
alias(libs.plugins.kotlin.android) apply false
54
alias(libs.plugins.kotlin.compose) apply false
65
}

gradle.properties

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,7 @@ android.enableJetifier=false
2222
kotlin.code.style=official
2323
org.gradle.unsafe.configuration-cache=true
2424
android.nonTransitiveRClass=false
25-
android.nonFinalResIds=false
26-
android.defaults.buildfeatures.resvalues=true
27-
android.sdk.defaultTargetSdkToCompileSdkIfUnset=false
28-
android.enableAppCompileTimeRClass=false
29-
android.usesSdkInManifest.disallowed=false
3025
android.uniquePackageNames=false
3126
android.dependency.useConstraints=true
3227
android.r8.strictFullModeForKeepRules=false
33-
android.r8.optimizedResourceShrinking=false
34-
android.builtInKotlin=false
35-
android.newDsl=false
28+
android.generateSyncIssueWhenLibraryConstraintsAreEnabled=false

gradle/libs.versions.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,5 @@ junit = { group = "junit", name = "junit", version.ref = "junit" }
123123
[plugins]
124124
android-application = { id = "com.android.application", version.ref = "agp" }
125125
android-library = { id = "com.android.library", version.ref = "agp" }
126-
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
127126
kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
128127
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }

0 commit comments

Comments
 (0)