You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React Native 0.74.5集成@rnmapbox/maps时Kotlin编译失败求助

React Native 0.74.5 升级后 @rnmapbox/maps 编译失败问题

首次在Stack Overflow发帖,若格式有误请告知修正方法,我会尽快调整。

将React Native从0.71.19升级到0.74.5后,项目无法加载,每次都会出现相同错误。我创建了一个测试模板项目排查是否为配置/安装问题或与其他包不兼容,已按照@rnmapbox/maps仓库中的安装指南操作(升级前可正常运行),但无论如何操作,最终都会出现:rnmapbox_maps:compileDebugKotlin执行失败的问题。

执行命令及错误日志

testMapbox@0.0.1 android
react-native run-android

info A dev server is already running for this project on port 8081.
info Installing the app...

Task :rnmapbox_maps:compileDebugKotlin FAILED
49 actionable tasks: 8 executed, 41 up-to-date

info 💡 Tip: Make sure that you have set up your development environment correctly, by running npx react-native doctor. To read more about doctor command visit: https://github.com/react-native-community/cli/blob/main/packages/cli-doctor/README.md#doctor

e: file:///C:/Users/npmye/Documents/testMapbox/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/components/images/RNMBXImagesManager.kt:212:5 'addView' overrides nothing
e: file:///C:/Users/npmye/Documents/testMapbox/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/components/images/RNMBXImagesManager.kt:227:5 'removeView' overrides nothing
e: file:///C:/Users/npmye/Documents/testMapbox/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/components/images/RNMBXImagesManager.kt:236:5 'removeAllViews' overrides nothing
e: file:///C:/Users/npmye/Documents/testMapbox/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXTileSourceManager.kt:13:5 'getChildAt' overrides nothing
e: file:///C:/Users/npmye/Documents/testMapbox/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXTileSourceManager.kt:17:5 'getChildCount' overrides nothing
e: file:///C:/Users/npmye/Documents/testMapbox/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXTileSourceManager.kt:21:5 'addView' overrides nothing
e: file:///C:/Users/npmye/Documents/testMapbox/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXTileSourceManager.kt:25:5 'removeViewAt' overrides nothing
e: file:///C:/Users/npmye/Documents/testMapbox/node_modules/@rnmapbox/maps/android/src/main/rn-compat/rn75/com/rnmapbox/rnmbx/rncompat/ResourceDrawableIdHelper.kt:5:37 Unresolved reference: Companion

FAILURE: Build failed with an exception.

What went wrong:
Execution failed for task ':rnmapbox_maps:compileDebugKotlin'.
A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
Compilation error. See log for more details

Try:
Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.
Get more help at https://help.gradle.org.

BUILD FAILED in 12s
error Failed to install the app. Command failed with exit code 1: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081

环境配置

  • Node.js v20.17.0
  • package.json 依赖:
"@rnmapbox/maps": "^10.1.30",
"react": "18.2.0",
"react-native": "0.74.5"
  • android/build.gradle 中的 ext 配置:
buildToolsVersion = "34.0.0"
minSdkVersion = 23
compileSdkVersion = 34
targetSdkVersion = 34
ndkVersion = "26.1.10909125"
kotlinVersion = "1.9.22"
RNMapboxMapsImpl = "mapbox"

复现步骤

  1. 创建 React Native 0.74.5 版本的测试项目
  2. 执行 npm install @rnmapbox/maps
  3. 按照官方指南完成配置
  4. 执行 npm run android --reset-cache

已尝试的操作

  • 纯 React Native 0.74.5 模板项目可正常运行
  • 回退到 @rnmapbox/maps@10.1.8(升级前使用的版本),问题仍存在
  • 可回退到旧版 React Native,但希望找到解决方案避免回退

内容的提问来源于stack exchange,提问作者Neil Myers

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.18 21:54:51