Current Syntax for Project/build.gradle plugins

What is the current syntax for adding plugins to the top-level Project/build.gradle file so that the changes listed in Listing 12.9 and Listing 13.9 work?
12.9: id 'org.jetbrains.kotlin.kapt' version '1.6.10' apply false
13.9: id 'androidx.navigation.safeargs.kotlin' version '2.4.1' apply false

Both changes give the same error:
e: file:///D:/Android/AndroidStudioProjects/CriminalIntent/build.gradle.kts:5:8: Unexpected tokens (use ';' to separate expressions on the same line)

I seem to be able to ignore adding the kapt plugin to the top-level gradle file, but the Safe Args plugin is giving me the most issues. If I use the instructions for adding Safe Args from: https://developer.android.com/guide/navigation/use-graph/safe-args that include adding the buildscript, I get a long error block

Build file 'D:\Android\AndroidStudioProjects\CriminalIntent\build.gradle.kts' line: 11

Plugin [id: 'androidx.navigation.safeargs.kotlin'] was not found in any of the following sources:

* Try:
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

* Exception is:
org.gradle.api.plugins.UnknownPluginException: Plugin [id: 'androidx.navigation.safeargs.kotlin'] was not found in any of the following sources:

- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Included Builds (No included builds contain this plugin)
- Plugin Repositories (plugin dependency must include a version number for this source) <6 internal lines>
	at Program.execute(Unknown Source) <91 internal lines>
	at com.intellij.gradle.toolingExtension.impl.modelAction.GradleModelFetchAction.lambda$initAction$6(GradleModelFetchAction.java:184)
	at com.intellij.gradle.toolingExtension.impl.telemetry.GradleOpenTelemetry.callWithSpan(GradleOpenTelemetry.java:73)
	at com.intellij.gradle.toolingExtension.impl.telemetry.GradleOpenTelemetry.callWithSpan(GradleOpenTelemetry.java:61)
	at com.intellij.gradle.toolingExtension.impl.modelAction.GradleModelFetchAction.initAction(GradleModelFetchAction.java:183)
	at com.intellij.gradle.toolingExtension.impl.modelAction.GradleModelFetchAction.doExecute(GradleModelFetchAction.java:138)
	at com.intellij.gradle.toolingExtension.impl.modelAction.GradleModelFetchAction.lambda$execute$1(GradleModelFetchAction.java:103)
	at com.intellij.gradle.toolingExtension.impl.telemetry.GradleOpenTelemetry.callWithSpan(GradleOpenTelemetry.java:73)
	at com.intellij.gradle.toolingExtension.impl.telemetry.GradleOpenTelemetry.callWithSpan(GradleOpenTelemetry.java:61)
	at com.intellij.gradle.toolingExtension.impl.modelAction.GradleModelFetchAction.lambda$execute$2(GradleModelFetchAction.java:102)
	at com.intellij.gradle.toolingExtension.impl.modelAction.GradleModelFetchAction.withOpenTelemetry(GradleModelFetchAction.java:113)
	at com.intellij.gradle.toolingExtension.impl.modelAction.GradleModelFetchAction.lambda$execute$3(GradleModelFetchAction.java:101)
	at com.intellij.gradle.toolingExtension.impl.util.GradleExecutorServiceUtil.withSingleThreadExecutor(GradleExecutorServiceUtil.java:18)
	at com.intellij.gradle.toolingExtension.impl.modelAction.GradleModelFetchAction.execute(GradleModelFetchAction.java:100)
	at com.intellij.gradle.toolingExtension.impl.modelAction.GradleModelFetchAction.execute(GradleModelFetchAction.java:36) <83 internal lines>

Hi, I managed to get these to work a few weeks ago but more by luck than judgement. First of all I noticed that my gradle used a implementation(“xx”) format, rather than the book’s single quotes… I later figured out that the format in the book is Groovy and that I had kotlin. Sometime later I noticed on the create project screen (the latest version of Fig 1.4) there is now an extra selection at the bottom, which defaults to kotlin. I think if you choose Groovy from the dropdown in the list it will probably use the format in the book. I dont know enough to figure out which you choose from the code you have put above.

Anyway if It’s any help, having chosen the default (kotlin), looking in my end of chapter 12 backup the following worked for me. Project level, after problems including kapt, I found it would work without it:
plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.kotlin.android) apply false
//id(“kotlin.kapt”) version(“2.6.1”) apply false
}
At application level
app level:
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
id(“kotlin-kapt”)
}

dependencies {
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.appcompat)
implementation(libs.material)
implementation(libs.androidx.activity)
implementation(libs.androidx.constraintlayout)
implementation(libs.androidx.fragment.ktx)
implementation(libs.androidx.lifecycle.viewmodel.ktx)
implementation(libs.androidx.recyclerview)
implementation(libs.org.jetbrains.kotlinx.kotlinx.coroutines.core)
implementation(libs.kotlinx.coroutines.android)
implementation(libs.lifecycle.runtime.ktx)
implementation (libs.androidx.room.runtime)
annotationProcessor(libs.androidx.room.compiler)
implementation (libs.room.ktx)
kapt(libs.androidx.room.compiler)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
}

The libs format is because at some stage I was floundering around and the warning messages were suggesting I switch the implementation (“xxxxxxx”) lines to lib format. I then wondered where the version numbers went and found them in libs.versions.toml (android studio automatically put them there when I chose the switch to lib format suggestion) copy of whole file below
[versions]
agp = “8.7.0”
fragmentKtx = “1.8.4”
kotlin = “1.9.23”
coreKtx = “1.13.1”
junit = “4.13.2”
junitVersion = “1.2.1”
espressoCore = “3.6.1”
appcompat = “1.7.0”
kotlinxCoroutinesAndroid = “1.6.0”
kotlinxCoroutinesAndroidVersion = “1.7.3”
kotlinxCoroutinesCore = “1.6.0”
kotlinxCoroutinesCoreVersion = “1.6.0”
lifecycleRuntimeKtx = “2.8.6”
lifecycleViewmodelKtx = “2.8.6”
material = “1.12.0”
activity = “1.9.2”
constraintlayout = “2.1.4”
recyclerview = “1.3.2”
roomKtx = “2.6.1”
roomRuntime = “2.6.1”

[libraries]
androidx-core-ktx = { group = “androidx.core”, name = “core-ktx”, version.ref = “coreKtx” }
androidx-fragment-ktx = { module = “androidx.fragment:fragment-ktx”, version.ref = “fragmentKtx” }
androidx-lifecycle-viewmodel-ktx = { module = “androidx.lifecycle:lifecycle-viewmodel-ktx”, version.ref = “lifecycleViewmodelKtx” }
androidx-recyclerview = { module = “androidx.recyclerview:recyclerview”, version.ref = “recyclerview” }
androidx-room-compiler = { module = “androidx.room:room-compiler”, version.ref = “roomRuntime” }
androidx-room-runtime = { module = “androidx.room:room-runtime”, version.ref = “roomRuntime” }
jetbrains-kotlinx-coroutines-android = { module = “org.jetbrains.kotlinx:kotlinx.coroutines-android”, version.ref = “kotlinxCoroutinesAndroid” }
junit = { group = “junit”, name = “junit”, version.ref = “junit” }
androidx-junit = { group = “androidx.test.ext”, name = “junit”, version.ref = “junitVersion” }
androidx-espresso-core = { group = “androidx.test.espresso”, name = “espresso-core”, version.ref = “espressoCore” }
androidx-appcompat = { group = “androidx.appcompat”, name = “appcompat”, version.ref = “appcompat” }
kotlinx-coroutines-android = { module = “org.jetbrains.kotlinx:kotlinx-coroutines-android”, version.ref = “kotlinxCoroutinesAndroidVersion” }
kotlinx-coroutines-core = { module = “org.jetbrains.kotlinx:kotlinx.coroutines-core”, version.ref = “kotlinxCoroutinesCore” }
lifecycle-runtime-ktx = { module = “androidx.lifecycle:lifecycle-runtime-ktx”, version.ref = “lifecycleRuntimeKtx” }
material = { group = “com.google.android.material”, name = “material”, version.ref = “material” }
androidx-activity = { group = “androidx.activity”, name = “activity”, version.ref = “activity” }
androidx-constraintlayout = { group = “androidx.constraintlayout”, name = “constraintlayout”, version.ref = “constraintlayout” }
org-jetbrains-kotlinx-kotlinx-coroutines-core = { module = “org.jetbrains.kotlinx:kotlinx-coroutines-core”, version.ref = “kotlinxCoroutinesCoreVersion” }
room-ktx = { module = “androidx.room:room-ktx”, version.ref = “roomKtx” }

[plugins]
android-application = { id = “com.android.application”, version.ref = “agp” }
kotlin-android = { id = “org.jetbrains.kotlin.android”, version.ref = “kotlin” }

This may be of no use whatsoever to you, but since you haven’t had any other replies I thought I’d tell you my experience. I’m finding it very frustrating that so much effort has to go into finding versions and formats that work. Though I’m getting things to work I dont think I’m really understanding stuff so am now taking a break after Chapter 20 to understand Kotlin better, then I think I’ll learn more about gradle before coming back to this book. If this was any use I have an end of Chapter 13 backup that I can give you info from. I see it’s date is oct 18th 2024 so it was at least working then…