From f3e7503e8d97426417fb0e0d755ec53fe878bd29 Mon Sep 17 00:00:00 2001 From: joaquinvaz Date: Wed, 22 Jul 2026 12:18:36 -0300 Subject: [PATCH] fix(android): register compat Kotlin source dirs for AGP 8.9+ (RN 0.86) AGP 8.9+ (bundled with RN 0.86 / Gradle 8.x) no longer feeds extra java.srcDirs into the Kotlin compile task. The compat directories added to java.srcDirs (mapbox-v11-compat, rn-compat and the selected lifecycle-compat variant) contain only Kotlin sources, so they were silently skipped and their packages (e.g. com.rnmapbox.rnmbx.v11compat) failed to resolve, breaking the Android build. Mirror those directories onto the Kotlin source set. Guarded by the same RNMapboxMapsImpl == "mapbox" check as the kotlin-android plugin, since only that impl registers the `kotlin` source set. --- android/build.gradle | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/android/build.gradle b/android/build.gradle index 7de0f2f4b7..c082fa096c 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -211,6 +211,18 @@ Please upgrade to Mapbox v11.x or use @rnmapbox/maps 10.2.x } } + // AGP 8.9+ (bundled with RN 0.86 / Gradle 8.x) no longer feeds + // extra java.srcDirs into the Kotlin compile task. The compat + // directories appended above (mapbox-v11-compat, rn-compat and the + // selected lifecycle-compat variant) contain only Kotlin sources, + // so without this they are silently skipped and their packages + // (e.g. com.rnmapbox.rnmbx.v11compat) fail to resolve. Mirror the + // Java source dirs onto the Kotlin source set to keep them compiled. + // Guarded by the same impl check as the `kotlin-android` plugin + // above, since only that impl registers the `kotlin` source set. + if (safeExtGet("RNMapboxMapsImpl", defaultMapboxMapsImpl) == "mapbox") { + kotlin.srcDirs(java.srcDirs) + } } }