rnmapbox / maps

A Mapbox react native module for creating custom maps
MIT License
2.27k stars 849 forks source link

Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'RNMBXMapViewModule' could not be found. #3193

Closed erwanlpfr closed 12 months ago

erwanlpfr commented 12 months ago

Environment

Steps to reproduce

Hello!

With :

I get this error after launching the bundler and displaying the map

Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'RNMBXMapViewModule' could not be found. Verify that a module by this name is registered in the native binary., js engine: hermes

This happens only with beta 21 with clear cache. It builds and starts with new arch activated, but my app is not ready yet. I wonder Mapbox is still compatible to old arch?

Thank you for your work!

I'm actually creating the repo to make you reproducing this! I edit this post soon

react-native init sample --version 0.72.7
cd sample
npm i @rnmapbox/maps@10.1.0-beta.21
react-native run-android

In App.tsx

import {MapView} from '@rnmapbox/maps';
import React from 'react';
import {SafeAreaView, StatusBar, useColorScheme} from 'react-native';
import {Colors} from 'react-native/Libraries/NewAppScreen';

function App() {
  const isDarkMode = useColorScheme() === 'dark';

  const backgroundStyle = {
    backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
  };

  return (
    <SafeAreaView style={backgroundStyle}>
      <StatusBar
        barStyle={isDarkMode ? 'light-content' : 'dark-content'}
        backgroundColor={backgroundStyle.backgroundColor}
      />
      <MapView style={{height: 300}} />
    </SafeAreaView>
  );
}

export default App;

Additional logs :


 LOG  Running "sample" with {"rootTag":11}
 ERROR  Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'RNMBXMapViewModule' could not be found. Verify that a module by this name is registered in the native binary., js engine: hermes 
    at App (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.sample&modulesOnly=false&runModule=true:122495:54)
    at RCTView
    at View (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.sample&modulesOnly=false&runModule=true:59470:43)
    at RCTView
    at View (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.sample&modulesOnly=false&runModule=true:59470:43)
    at AppContainer (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.sample&modulesOnly=false&runModule=true:59314:36)
    at sample(RootComponent) (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.sample&modulesOnly=false&runModule=true:108030:28)
 ERROR  Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'RNMBXMapViewModule' could not be found. Verify that a module by this name is registered in the native binary., js engine: hermes 
    at App (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.sample&modulesOnly=false&runModule=true:122495:54)
    at RCTView
    at View (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.sample&modulesOnly=false&runModule=true:59470:43)
    at RCTView
    at View (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.sample&modulesOnly=false&runModule=true:59470:43)
    at AppContainer (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.sample&modulesOnly=false&runModule=true:59314:36)
    at sample(RootComponent) (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.sample&modulesOnly=false&runModule=true:108030:28)
 ERROR  TypeError: Cannot read property 'MapView' of undefined

This error is located at:
    in App
    in RCTView (created by View)
    in View (created by AppContainer)
    in RCTView (created by View)
    in View (created by AppContainer)
    in AppContainer
    in sample(RootComponent), js engine: hermes
 ERROR  TypeError: Cannot read property 'MapView' of undefined

This error is located at:
    in App
    in RCTView (created by View)
    in View (created by AppContainer)
    in RCTView (created by View)
    in View (created by AppContainer)
    in AppContainer
    in sample(RootComponent), js engine: hermes
mfazekas commented 12 months ago

@erwanlpfr are you sure you can repro it on a project created with react-native init? We do support old-arch for sure

erwanlpfr commented 12 months ago

@mfazekas As it, I get the issue, you can follow the repro!

ysainson commented 12 months ago

Experiencing this issue on Android with 10.1.0-beta.21. No problems on iOS.

Old arch
Mapbox: 11.0.0-rc.1

expo: 49.0.18
react-native: 0.72.6
rnmapbox/maps: 10.1.0-beta.21
Jzuni97 commented 12 months ago

Haven't tested in android, but I get this issue for iOS devices. I have an expo managed project with the following configuration:

App config

[
  "@rnmapbox/maps",
  {
    RNMapboxMapsImpl: "mapbox",
    RNMapboxMapsVersion: "11.0.0-beta.5",
    RNMapboxMapsDownloadToken:
      "sk...",
    RNMapboxMapsUseV11: true,
  },
],

Module Versions

@rnmapbox/maps: 10.1.0-beta.21
expo: ^49.0.16
react-native: 0.72.4
mfazekas commented 12 months ago

Can you try with rc? We might not be able with build with beta.5

 RNMapboxMapsVersion: "11.0.0-beta.5",
erwanlpfr commented 12 months ago

Hello ! With beta 22, I still have the issue :

So with beta22 and mapbox v10 I still can the previous error message. With beta22 and :

RNMapboxMapsImpl = "mapbox"
RNMapboxMapsVersion = "11.0.0-rc.2"
RNMapboxMapsUseV11 = true

I get :

> Task :rnmapbox_maps:compileDebugKotlin FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/8.0.1/userguide/command_line_interface.html#sec:command_line_warnings
825 actionable tasks: 30 executed, 795 up-to-date

info 💡 Tip: Make sure that you have set up your development environment correctly, by running 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:///Users/erwanleprado/Documents/app-user/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/modules/RNMBXLocationModule.kt:59:51 Type mismatch: inferred type is com.rnmapbox.rnmbx.v11compat.location.Location /* = com.mapbox.common.location.Location */ but com.rnmapbox.rnmbx.v11compat.location.Location /* = android.location.Location */ was expected
e: file:///Users/erwanleprado/Documents/app-user/node_modules/@rnmapbox/maps/android/src/main/java/com/rnmapbox/rnmbx/modules/RNMBXLocationModule.kt:110:59 Type mismatch: inferred type is com.rnmapbox.rnmbx.v11compat.location.Location /* = com.mapbox.common.location.Location */ but com.rnmapbox.rnmbx.v11compat.location.Location /* = android.location.Location */ was expected

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

Any idea? Reproducible with the react native init.

mfazekas commented 12 months ago

Reproducible with the react native init.

Is it? You're using expo aren't you?!

Have you verified your RNMapboxMapsDownloadToken has the right permissions?

erwanlpfr commented 12 months ago

No, no Expo, pure React Native 0.72.7 !

I just retried and here, you can find the repro. It downloads well with my token. It is working in production fine.

npx react-native init sample --version 0.72.7
cd sample
npm i @rnmapbox/maps@10.1.0-beta.22
npx react-native run-android
 LOG  Running "sample" with {"rootTag":11}
 ERROR  Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'RNMBXMapViewModule' could not be found. Verify that a module by this name is registered in the native binary., js engine: hermes
    at App (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.sample&modulesOnly=false&runModule=true:122489:54)
    at RCTView
    at View (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.sample&modulesOnly=false&runModule=true:59470:43)
    at RCTView
    at View (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.sample&modulesOnly=false&runModule=true:59470:43)
    at AppContainer (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.sample&modulesOnly=false&runModule=true:59314:36)
    at sample(RootComponent) (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.sample&modulesOnly=false&runModule=true:108030:28)
 ERROR  Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'RNMBXMapViewModule' could not be found. Verify that a module by this name is registered in the native binary., js engine: hermes
    at App (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.sample&modulesOnly=false&runModule=true:122489:54)
    at RCTView
    at View (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.sample&modulesOnly=false&runModule=true:59470:43)
    at RCTView
    at View (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.sample&modulesOnly=false&runModule=true:59470:43)
    at AppContainer (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.sample&modulesOnly=false&runModule=true:59314:36)
    at sample(RootComponent) (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&minify=false&app=com.sample&modulesOnly=false&runModule=true:108030:28)
 ERROR  TypeError: Cannot read property 'MapView' of undefined

This error is located at:
    in App
    in RCTView (created by View)
    in View (created by AppContainer)
    in RCTView (created by View)
    in View (created by AppContainer)
    in AppContainer
    in sample(RootComponent), js engine: hermes
 ERROR  TypeError: Cannot read property 'MapView' of undefined

This error is located at:
    in App
    in RCTView (created by View)
    in View (created by AppContainer)
    in RCTView (created by View)
    in View (created by AppContainer)
    in AppContainer
    in sample(RootComponent), js engine: hermes

It looks like it came from this commit ? https://github.com/rnmapbox/maps/compare/v10.1.0-beta.20...v10.1.0-beta.21#diff-e41dc52beb74b889c738e750118cdb5bb8b3ab2ee412a77b3a248b2b394e1d01R25

Thank you for your work!

EDIT : Okay, I found my workaround. In NativeMapViewModuleSpec.java I added the interface : ReactModuleWithSpec as removed in the previous commit. Looks like deprecated as I see on React Native, but it is the fattest workaround. Maybe, it is specific react native <= 72?

mfazekas commented 12 months ago

@erwanlpfr thank much, yes so in beta.21 and 22 I've upgraded the codegen to 0.73 and it seems that 0.73 generates code for oldgen that's no longer compatible with 0.72. Ugh.... so even if our example is 0.73 we still need to use 0.72 codegen to generate code that's compatible with older versions.

mfazekas commented 11 months ago

@erwanlpfr thanks much for the report. 👍

I've release a new beta 23 which should fix the issue

erwanlpfr commented 11 months ago

Thanks a lot for taking time on this! 👍🏻

ysainson commented 11 months ago

I can confirm that the issue has been resolved in version 10.1.0-beta.23. Thanks @mfazekas!

AshwinPetari commented 10 months ago

@mfazekas This issue still occurs with RN: 0.73.1 and rnmapbox/maps@10.1.3. Any solution for this?

`Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'RNMBXMapViewModule' could not be found. Verify that a module by this name is registered in the native binary.Bridgeless mode: false. TurboModule interop: false. Modules loaded: {"NativeModules":["PlatformConstants","LogBox","Timing","AppState","SourceCode","BlobModule","WebSocketModule","SettingsManager","DevSettings","RedBox","Networking","Appearance","DevLoadingView","UIManager","DeviceInfo","ImageLoader","LinkingManager","RNCSafeAreaContext","I18nManager","NativeAnimatedModule"],"TurboModules":[],"NotFound":["NativePerformanceCxx","NativePerformanceObserverCxx","BugReporting","HeadlessJsTaskSupport","SoundManager","IntentAndroid","RNMBXMapViewModule"]}, js engine: hermes

ERROR Error: Exception in HostObject::get for prop 'RNMBXLocationModule': java.lang.NoClassDefFoundError: Failed resolution of: Lcom/mapbox/android/core/location/LocationEngineCallback;, js engine: hermes`

AdzeB commented 10 months ago

Can confirm I am getting the same issue for this but I am on v10.1.3-rc.0

atif089 commented 10 months ago

I'm facing the same issue in the following environment

daveyholler commented 10 months ago

I'm getting the same issue with the following:

mfazekas commented 10 months ago

Can you reproduce with a new project from npx create-expo-app ?! Can you post the steps to reproduce and a link to a repo (pls do not include access tokens).

NitayMG commented 10 months ago

Got this error too: ERROR Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'RNMBXMapViewModule' could not be found. Verify that a module by this name is registered in the native binary., js engine: hermes

using react native with Expo expo ver: 48.0.21 react native ver: 0.71.14 everything works just fine till I update from @rnmapbox/maps 10.0.15 to @rnmapbox/maps 10.1.5

NitayMG commented 10 months ago

Can you reproduce with a new project from npx create-expo-app ?! Can you post the steps to reproduce and a link to a repo (pls do not include access tokens).

steps to reproduce: create account at mapbox...create token with download:read npx create-expo-app MYAPP npm install @rnmapbox/maps add to app.json: "plugins": [ [ "@rnmapbox/maps", { "RNMapboxMapsImpl": "mapbox", "RNMapboxMapsDownloadToken": "sk.", "RNMapboxMapsVersion": "11.0.0", "RNMapboxMapsUseV11": true } ] ] }

make simple component with mapbox:

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

Mapbox.setAccessToken('');

const App = () => { return (

); }

export default App;

const styles = StyleSheet.create({ page: { flex: 1, justifyContent: 'center', alignItems: 'center', }, container: { height: 300, width: 300, }, map: { flex: 1 } });

When you try to run it on emulator with: npx expo start --dev-client you will get this crash

Omkar001-afk commented 10 months ago

I am facing the following issue, Error: @rnmapbox/maps native code not available. Make sure you have linked the library and rebuild your app. See https://rnmapbox.github.io/docs/install?rebuild=expo#rebuild, js engine: hermes Image (1) Image image

NitayMG commented 10 months ago

STEPS To fix: 1.npm update

  1. npm install -g eas-cli
  2. npx expo install expo-dev-client 4.eas build --profile development --platform android
  3. for run on andorid emulator: npx expo start --dev-client
Omkar001-afk commented 10 months ago

is there any other packages to install image

NitayMG commented 10 months ago

You need to update and after the update do a rebuild to your emulator:

Omkar001-afk commented 9 months ago

Thanks its working and is there any other steps for production.

NitayMG commented 9 months ago

For making an apk you use this command: eas build -p android --profile preview

brianestadimas commented 8 months ago

This issue is not yet solved

whitewaterdesign commented 8 months ago

Same issue here on npx expo run:ios

"@rnmapbox/maps": "^10.1.18",
[
        '@rnmapbox/maps',
        {
          RNMapboxMapsDownloadToken: [SECRET_ACCESS_TOKEN_WITH_DOWNLOAD_PERMISSIONS],
          RNMapboxMapsVersion: '11.1.0',
        },
 ]
tortortortortortor commented 8 months ago

same issue here.

image image image

My fix was opening the project on android, and auto resolving the issue,

image

to

image