Skip to content

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

Description

@joaquinvaz

Mapbox Version

default

React Native Version

0.86.0

Platform

Android

@rnmapbox/maps version

10.3.2

Standalone component to reproduce

import React from 'react';
import { View } from 'react-native';
import Mapbox, { MapView } from '@rnmapbox/maps';

Mapbox.setAccessToken('<YOUR_TOKEN>');

export default function App() {
  // The failure is at Android build time (AGP 8.9+ / RN 0.86), not at runtime.
  // Merely depending on @rnmapbox/maps@10.3.2 and building for Android
  // reproduces it — this component just makes the dependency compile in.
  return (
    <View style={{ flex: 1 }}>
      <MapView style={{ flex: 1 }} />
    </View>
  );
}

Observed behavior and steps to reproduce

Building the Android app fails to compile @rnmapbox/maps — unresolved-reference errors for the com.rnmapbox.rnmbx.v11compat and com.rnmapbox.rnmbx.rncompat packages (Kotlin sources under android/src/main/mapbox-v11-compat/v11 and android/src/main/rn-compat/rn75).

Steps:

  1. RN 0.86 app, New Architecture enabled → Gradle 8.14.3 / AGP 8.9+.
  2. yarn add @rnmapbox/maps@10.3.2.
  3. Add the component above.
  4. cd android && ./gradlew :rnmapbox_maps:compileDebugKotlin (or build the app).
  5. Kotlin compilation fails — the .kt files in the compat dirs are never compiled.

Root cause: android/build.gradle registers those dirs only via java.srcDirs +=; on AGP 8.9+ that no longer adds them as Kotlin source roots for compileKotlin.

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 compat directories are added as Java source roots only, but they contain .kt files:

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

On AGP 8.9+, appending to java.srcDirs no longer implicitly registers the directory as a Kotlin source root for the compileKotlin task, so those .kt files are silently skipped.

Registering them as Kotlin source dirs as well fixes it:

sourceSets {
    main {
        java.srcDirs = ['src/main/java']
        java.srcDirs += 'src/main/mapbox-v11-compat/v11'
        java.srcDirs += 'src/main/rn-compat/rn75'

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

The same java.srcDirs += 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.

Environment:

  • @rnmapbox/maps: 10.3.2
  • React Native: 0.86.0 (New Architecture enabled)
  • Gradle: 8.14.3 (AGP 8.9+)
  • Package manager: Yarn 3.6.4

Additional links and references

  • AGP 8.9 changes to sourceSets / Kotlin source-set handling (source of the regression).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🪲Something isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions