From 318b521d87bcbbeba12bff76fdbbd48345acb4c8 Mon Sep 17 00:00:00 2001 From: Joachim Nelson Date: Wed, 1 Jul 2026 14:32:46 +0200 Subject: [PATCH 1/2] Fix Dokka 1.x compatibility with AGP 8.7.3 Dokka 1.x crashes with a NPE when auto-discovering source sets on AGP 8.7+ due to androidTest source set builder creation failing. Bump Dokka to 1.9.20 and manually register source sets instead of using configureEach, which avoids the problematic auto-discovery. Co-Authored-By: Claude Opus 4.6 (1M context) --- auth-lib/build.gradle.kts | 44 ++++++++++++++++++--------------------- build.gradle.kts | 2 +- 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/auth-lib/build.gradle.kts b/auth-lib/build.gradle.kts index 40f314b..12bf77e 100644 --- a/auth-lib/build.gradle.kts +++ b/auth-lib/build.gradle.kts @@ -200,34 +200,30 @@ afterEvaluate { tasks.register(dokkaTaskName, DokkaTask::class.java) { description = "Generates Dokka documentation for ${variant.name}." - // Configure source sets - dokkaSourceSets { - configureEach { - // Include both Kotlin and Java sources - val sourceDirs = variant.sourceSets.flatMap { - it.javaDirectories - } - sourceDirs.forEach { sourceDir -> - if (sourceDir.exists()) { - this@configureEach.sourceRoots.from(sourceDir) - } + // Dokka 1.x crashes with AGP 8.7 when auto-discovering source sets + // (NPE on androidTest sets). Clear and manually register. + @Suppress("DEPRECATION") + dokkaSourceSets.clear() + dokkaSourceSets.register(variant.name) { + variant.sourceSets.flatMap { + it.javaDirectories + it.kotlinDirectories + }.forEach { sourceDir -> + if (sourceDir.exists()) { + sourceRoots.from(sourceDir) } + } - // Configure classpath - classpath.from(variant.javaCompileProvider.get().classpath) - classpath.from(project.files(android.bootClasspath.joinToString(File.pathSeparator))) + classpath.from(variant.javaCompileProvider.get().classpath) + classpath.from(project.files(android.bootClasspath.joinToString(File.pathSeparator))) - // External documentation links - externalDocumentationLink { - url.set(uri("https://docs.oracle.com/javase/8/docs/api/").toURL()) - } - externalDocumentationLink { - url.set(uri("https://developer.android.com/reference/").toURL()) - } - - // Suppress warnings for undocumented code (optional) - suppressInheritedMembers.set(false) + externalDocumentationLink { + url.set(uri("https://docs.oracle.com/javase/8/docs/api/").toURL()) + } + externalDocumentationLink { + url.set(uri("https://developer.android.com/reference/").toURL()) } + + suppressInheritedMembers.set(false) } // Output directory diff --git a/build.gradle.kts b/build.gradle.kts index 435a28c..f615907 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -29,7 +29,7 @@ buildscript { dependencies { classpath("com.android.tools.build:gradle:8.7.3") classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion") - classpath("org.jetbrains.dokka:dokka-gradle-plugin:1.9.10") + classpath("org.jetbrains.dokka:dokka-gradle-plugin:1.9.20") } } From 49df751809e9fc5eb552887b99fd3c467d1506c7 Mon Sep 17 00:00:00 2001 From: Joachim Nelson Date: Thu, 2 Jul 2026 05:37:24 +0200 Subject: [PATCH 2/2] Fix Dokka 1.x compatibility with AGP 8.7.3 Dokka 1.x crashes with a NPE when auto-discovering androidTest source sets on AGP 8.7+. Work around it by clearing auto-discovered source sets and manually registering only the variant being documented. Also bump Dokka from 1.9.10 to 1.9.20. Co-Authored-By: Claude Opus 4.6 (1M context) --- auth-lib/build.gradle.kts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/auth-lib/build.gradle.kts b/auth-lib/build.gradle.kts index 12bf77e..c9b819e 100644 --- a/auth-lib/build.gradle.kts +++ b/auth-lib/build.gradle.kts @@ -200,11 +200,12 @@ afterEvaluate { tasks.register(dokkaTaskName, DokkaTask::class.java) { description = "Generates Dokka documentation for ${variant.name}." - // Dokka 1.x crashes with AGP 8.7 when auto-discovering source sets - // (NPE on androidTest sets). Clear and manually register. + // Dokka 1.x NPEs on androidTest source sets with AGP 8.7+. + // Clear auto-discovered sets and register only this variant. @Suppress("DEPRECATION") dokkaSourceSets.clear() dokkaSourceSets.register(variant.name) { + // Include both Kotlin and Java sources variant.sourceSets.flatMap { it.javaDirectories + it.kotlinDirectories }.forEach { sourceDir -> @@ -213,9 +214,11 @@ afterEvaluate { } } + // Configure classpath classpath.from(variant.javaCompileProvider.get().classpath) classpath.from(project.files(android.bootClasspath.joinToString(File.pathSeparator))) + // External documentation links externalDocumentationLink { url.set(uri("https://docs.oracle.com/javase/8/docs/api/").toURL()) } @@ -223,6 +226,7 @@ afterEvaluate { url.set(uri("https://developer.android.com/reference/").toURL()) } + // Suppress warnings for undocumented code (optional) suppressInheritedMembers.set(false) }