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

Open Beginner friendly
#4,263 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
android, kotlin, react-native

Research direction

Start in android/build.gradle and inspect every mapbox-v11-compat and rn-compat source-set entry, then run :rnmapbox_maps:compileDebugKotlin with the reported AGP and React Native versions. Done means the Kotlin files in the compat directories are included in compilation and the Android build completes without a consumer-side patch.

Written by the indexing model from the issue text.

Description

bug 🪲 Needs: Author Feedback
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).
Dominant language
Kotlin
Stars
2.9k
Forks
947
Avg merge
8d 4h
Merged PRs (30d)
2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rnmapbox/maps

All issues in rnmapbox/maps

Similar issues

More Kotlin issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.