From e60c054e478de2e305f019fa6b9d7bfb7011b255 Mon Sep 17 00:00:00 2001 From: Martin Guillon Date: Wed, 21 Oct 2026 17:18:39 +0200 Subject: [PATCH] fix(android): include AGP 9 built-in Kotlin classes in metadata generation AGP 9 compiles Kotlin into intermediates/built_in_kotlinc//compileKotlin/classes instead of tmp/kotlin-classes, so buildMetadata never saw the app's Kotlin classes. They were missing from the metadata and resolved to undefined in JS (e.g. com.akylas.weather.WeatherIconProviderRegistry). Co-Authored-By: Claude Sonnet 5.5 --- vendor/gradle-app/app/build.gradle | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/vendor/gradle-app/app/build.gradle b/vendor/gradle-app/app/build.gradle index 22257959fa..f3ca91a5d8 100644 --- a/vendor/gradle-app/app/build.gradle +++ b/vendor/gradle-app/app/build.gradle @@ -1308,6 +1308,12 @@ task buildMetadata(type: BuildToolTask) { inputs.dir(kotlinClassesDir) } + // AGP 9 built-in Kotlin no longer writes to tmp/kotlin-classes + def builtInKotlinClassesDir = layout.buildDirectory.dir("intermediates/built_in_kotlinc").get().asFile + if (builtInKotlinClassesDir.exists()) { + inputs.dir(builtInKotlinClassesDir) + } + outputs.files("$METADATA_OUT_PATH/treeNodeStream.dat", "$METADATA_OUT_PATH/treeStringsStream.dat", "$METADATA_OUT_PATH/treeValueStream.dat") workingDir "$BUILD_TOOLS_PATH" @@ -1320,6 +1326,7 @@ task buildMetadata(type: BuildToolTask) { def classesSubDirs = [] def kotlinClassesSubDirs = [] + def builtInKotlinClassesDirs = [] def selectedBuildType = project.ext.selectedBuildType rootProject.subprojects { @@ -1344,6 +1351,17 @@ task buildMetadata(type: BuildToolTask) { } } } + + // AGP 9 built-in Kotlin: intermediates/built_in_kotlinc//compileKotlin/classes + def projectBuiltInKotlinDir = it.layout.buildDirectory.dir("intermediates/built_in_kotlinc/${selectedBuildType}").get().asFile + if (projectBuiltInKotlinDir.exists()) { + for (File taskDir : projectBuiltInKotlinDir.listFiles()) { + def builtInClasses = new File(taskDir, "classes") + if (builtInClasses.exists() && !builtInKotlinClassesDirs.contains(builtInClasses)) { + builtInKotlinClassesDirs.add(builtInClasses) + } + } + } } def generatedClasses = new LinkedList() @@ -1359,6 +1377,10 @@ task buildMetadata(type: BuildToolTask) { } } + for (File builtInClasses : builtInKotlinClassesDirs) { + generatedClasses.add(builtInClasses.getAbsolutePath()) + } + def store = new ArrayList() for (String dir : generatedClasses) { listf(dir, store)