admin管理员组文章数量:1202579
I'm trying to use RNCamera in a simple project to make use of my device camera. But I get the following error on my android device -
Attempt to invoke vitual method 'com.facebook.react.uimanager.events.EventDispatcher.facebook.react.uimanager.UiManagerModule.getEventDispatcher()' on a null object reference
I'm on RN 0.76.6
This is App.js
import React from 'react';
import Camera from './components/Camera';
import { SafeAreaView } from 'react-native';
const App = () => {
return (
<SafeAreaView style={{ flex: 1 }}>
<Camera />
</SafeAreaView>
);
};
export default App;
Here is my Camera.js
import React, {PureComponent} from 'react';import {RNCamera} from 'react-native-camera';
export default class Camera extends PureComponent { constructor(props) {
super(props);}
render() {
return (
<RNCamera
ref={ref => {
this.camera = ref;
}}
captureAudio={false}
style={{flex: 1}}
type={RNCamera.Constants.Type.back}
androidCameraPermissionOptions={{
title: 'Permission to use camera',
message: 'We need your permission to use your camera',
buttonPositive: 'Ok',
buttonNegative: 'Cancel',
}} />
);
}}
And finally my package.json
{
"name": "AwesomeCamera",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"lint": "eslint .",
"start": "react-native start",
"test": "jest"
},
"dependencies": {
"react": "18.3.1",
"react-native": "0.76.6",
"react-native-camera": "^4.2.1",
"react-native-vector-icons": "^10.2.0"
},
"devDependencies": {
"@babel/core": "^7.25.2",
"@babel/preset-env": "^7.25.3",
"@babel/runtime": "^7.25.0",
"@react-native-community/cli": "15.0.1",
"@react-native-community/cli-platform-android": "15.0.1",
"@react-native-community/cli-platform-ios": "15.0.1",
"@react-native/babel-preset": "0.76.6",
"@react-native/eslint-config": "0.76.6",
"@react-native/metro-config": "0.76.6",
"@react-native/typescript-config": "0.76.6",
"@types/react": "^18.2.6",
"@types/react-test-renderer": "^18.0.0",
"babel-jest": "^29.6.3",
"eslint": "^8.19.0",
"jest": "^29.6.3",
"prettier": "2.8.8",
"react-test-renderer": "18.3.1",
"typescript": "5.0.4"
},
"engines": {
"node": ">=18"
}
}
本文标签: react nativeAttempt to invoke virtual method on a null object reference RNCamera issueStack Overflow
版权声明:本文标题:react native - Attempt to invoke virtual method on a null object reference RNCamera issue - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738651685a2104906.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论