Skip to content

[Bug]: Android build fails on AGP 8.9+ (RN 0.86): mapbox-v11-compat / rn-compat Kotlin sources not compiled #4262

Description

@joaquinvaz

Mapbox Version

default

React Native Version

0.86.0

Platform

Android

@rnmapbox/maps version

10.3.2

Standalone component to reproduce

This is a build-time (Gradle) failure, not a runtime/JS issue, so it can't be reproduced with a standalone component. It reproduces from configuration alone:

  1. A React Native 0.86 app with the New Architecture enabled (Gradle 8.14.3 / AGP 8.9+).
  2. @rnmapbox/maps@10.3.2 added as a dependency.
  3. cd android && ./gradlew :rnmapbox_maps:compileDebugKotlin (or a full app build).

Minimal android/build.gradle (app) relevant bits:

// gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
// AGP resolved via the RN 0.86 gradle plugin (8.9+)

Observed behavior and steps to reproduce

Building the Android app fails with unresolved-reference errors for symbols defined under android/src/main/mapbox-v11-compat/v11 and android/src/main/rn-compat/rn75 (e.g. the com.rnmapbox.rnmbx.v11compat and com.rnmapbox.rnmbx.rncompat packages).

Steps:

  1. Use RN 0.86 (New Arch) → Gradle 8.14.3 / AGP 8.9+.
  2. Install @rnmapbox/maps@10.3.2.
  3. Build the Android app (or run :rnmapbox_maps:compileDebugKotlin).
  4. Compilation fails because the .kt files in the compat directories are never compiled.

Root cause: android/build.gradle registers those directories only via java.srcDirs +=. On AGP 8.9+, appending to java.srcDirs no longer implicitly adds the directory as a Kotlin source root for the compileKotlin task, so the .kt files there are silently skipped.

Expected behavior

  • The Kotlin sources under mapbox-v11-compat/* and rn-compat/* should be compiled on AGP 8.9+ (RN 0.86), the same as on older AGP versions.
  • The Android build should succeed without a consumer-side patch.

Notes / preliminary analysis

The directories are added as Java source roots only:

java.srcDirs += 'src/main/mapbox-v11-compat/v11'
java.srcDirs += 'src/main/rn-compat/rn75'

but they contain .kt files. Registering them as Kotlin source dirs as well fixes it:

kotlin {
    srcDir 'src/main/mapbox-v11-compat/v11'
    srcDir 'src/main/rn-compat/rn75'
}

The same pattern is used for other mapbox-v11-compat / rn-compat variants in the file, so they likely need the same treatment. Confirmed working via a yarn patch on android/build.gradle.

Additional links and references

  • AGP 8.9 release notes / changes to sourceSets and Kotlin source handling.
  • (Add your PR link here if you open one with the kotlin { srcDir ... } fix.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions