I am developing my first native modules, for iOS & Android. On iOS, I have no problems. On Android, the development build works fine. However, when I bundle for production build, the app crashes. I think it’s related to this error in adb logcat
:
2024-12-08 20:49:20.531 29294-29339 ReactNativeJS com.identafly.preview E Error: Cannot find native module 'BoundingBox', js engine: hermes
2024-12-08 20:49:20.537 29294-29340 AndroidRuntime com.identafly.preview E FATAL EXCEPTION: mqt_native_modules
Process: com.identafly.preview, PID: 29294
com.facebook.react.common.JavascriptException: Error: Cannot find native module 'BoundingBox', js engine: hermes, stack:
requireNativeModule@1:688911
What could be different between dev & production bundles in the way it imports my android
content:
// expo-module.config.json
{
"platforms": ["ios", "tvos", "android", "web"],
"ios": {
"modules": ["BoundingBoxModule"]
},
"android": {
"modules": ["expo.modules.boundingbox.BoundingBoxModule"]
}
}
which references my JS module layer:
// modules/bounding-box/index.ts
import { type BoundingBoxProps } from './src/BoundingBox.types';
// Import the native module. On web, it will be resolved to BoundingBox.web.ts
// and on native platforms to BoundingBox.ts
import BoundingBoxModule from './src/BoundingBoxModule';
const drawBoundingBox = (props?: BoundingBoxProps) => {
if (
BoundingBoxModule &&
typeof BoundingBoxModule.drawBoundingBox === 'function'
) {
BoundingBoxModule.drawBoundingBox(props?.boundingBox, props?.color);
} else {
console.error('drawBoundingBox method not found');
}
};
export { BoundingBoxProps, drawBoundingBox };
and the native require:
// modules/bounding-box/src/BoundingBoxModule.ts
import { requireNativeModule } from 'expo-modules-core';
// It loads the native module object from the JSI or falls back to
// the bridge module (from NativeModulesProxy) if the remote debugger is on.
export default requireNativeModule('BoundingBox');
Is there something different between dev & prod JS bundles? Something else?