[Bug]: Android build fails on AGP 8.9+ (RN 0.86): mapbox-v11-compat / rn-compat Kotlin sources not compiled
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
- Domain
- build-system, mobile
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
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:
- RN 0.86 app, New Architecture enabled → Gradle 8.14.3 / AGP 8.9+.
yarn add @rnmapbox/maps@10.3.2.- Add the component above.
cd android && ./gradlew :rnmapbox_maps:compileDebugKotlin(or build the app).- Kotlin compilation fails — the
.ktfiles 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/*andrn-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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from rnmapbox/maps
-
bug 🪲
Difficulty 1/5 Under an hour Newbie friendliness 90/100
-
bug 🪲
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
bug 🪲
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
bug 🪲
Difficulty 1/5 Under an hour Newbie friendliness 86/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Anthonyy232/Paperize#614 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
bitcoindevkit/bdk-ffi#1125 ·
-
Issue: Bug
Difficulty 1/5 Under an hour Newbie friendliness 91/100
OpenAPITools/openapi-generator#24978 ·
-
helsemelding-json-schema json-schema-core
Difficulty 2/5 1-3 hours Newbie friendliness 68/100