I use react-native-camera to scan barcodes. But if I use react-native-navigation as navigation solution I get the following error: Undefined is not an object (evaluating 'CameraManager.Aspcet')
I tried to look up what's the problem and found out that if I extend SplashActivity instead of ReactActivity in MainActivity.java the error occurs. But if I not extend SplashActivity the navigation doesn't work.
Do you have a solution for that? Can I use any workaround? Is it a "failure" in your implementation or of the other package? Should I better use another navigation package like react-navigation?
I also found out that I am not alone with the problem but no one asked for a solution here.
Create new project with react-native init myProject
Install react-native-camera and use the base implementation example
Install this navigation plugin
I use react-native-camera with this package but I don't use it to scan barcodes.
I have had no problems with integrating the two.
Can or did you verify it only happens with scanning barcodes?
It's expecting CameraManager to be defined but it was not.
This sometimes happens when you're not importing correctly.
Make sure you're doing:
import CameraManager from 'react-native-camera'
instead of:
import {CameraManager} from 'react-native-camera'
This happens already when importing react-native-camera, and only if extending from SplashActivity.
import { RNCamera } from 'react-native-camera';
->
_ReactNativeJS: undefined is not an object (evaluating 'CameraManager.Aspect')_
Where that happens is in react-native-camera/src/Camera.js
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import {
DeviceEventEmitter, // android
NativeAppEventEmitter, // ios
NativeModules,
Platform,
StyleSheet,
findNodeHandle,
requireNativeComponent,
ViewPropTypes,
PermissionsAndroid,
ActivityIndicator,
View,
Text,
UIManager,
} from 'react-native';
import { requestPermissions } from './handlePermissions';
const CameraManager = NativeModules.CameraManager || NativeModules.CameraModule;
console.log(CameraManager);
This prints
03-11 16:30:22.764 17169 17200 I ReactNativeJS: { capture: { [Function: fn] type: 'promise' },
03-11 16:30:22.764 17169 17200 I ReactNativeJS: hasFlash: { [Function: fn] type: 'promise' },
03-11 16:30:22.764 17169 17200 I ReactNativeJS: setZoom: { [Function: fn] type: 'async' },
03-11 16:30:22.764 17169 17200 I ReactNativeJS: stopCapture: { [Function: fn] type: 'promise' },
03-11 16:30:22.764 17169 17200 I ReactNativeJS: FlashMode: { on: 1, off: 0, auto: 2 },
03-11 16:30:22.764 17169 17200 I ReactNativeJS: Orientation:
03-11 16:30:22.764 17169 17200 I ReactNativeJS: { landscapeLeft: 1,
03-11 16:30:22.764 17169 17200 I ReactNativeJS: portrait: 0,
03-11 16:30:22.764 17169 17200 I ReactNativeJS: auto: 2147483647,
03-11 16:30:22.764 17169 17200 I ReactNativeJS: landscapeRight: 3,
03-11 16:30:22.764 17169 17200 I ReactNativeJS: portraitUpsideDown: 2 },
03-11 16:30:22.764 17169 17200 I ReactNativeJS: BarCodeType: {},
03-11 16:30:22.764 17169 17200 I ReactNativeJS: TorchMode: { on: 1, off: 0, auto: 2 },
03-11 16:30:22.764 17169 17200 I ReactNativeJS: CaptureMode: { video: 1, still: 0 },
03-11 16:30:22.764 17169 17200 I ReactNativeJS: CaptureQuality:
03-11 16:30:22.764 17169 17200 I ReactNativeJS: { '480p': '480p',
03-11 16:30:22.764 17169 17200 I ReactNativeJS: photo: 'high',
03-11 16:30:22.764 17169 17200 I ReactNativeJS: low: 'low',
03-11 16:30:22.764 17169 17200 I ReactNativeJS: '720p': '720p',
03-11 16:30:22.764 17169 17200 I ReactNativeJS: medium: 'medium',
03-11 16:30:22.764 17169 17200 I ReactNativeJS: '1080p': '1080p',
03-11 16:30:22.764 17169 17200 I ReactNativeJS: high: 'high',
03-11 16:30:22.764 17169 17200 I ReactNativeJS: preview: 'preview' },
03-11 16:30:22.764 17169 17200 I ReactNativeJS: CaptureTarget: { memory: 0, temp: 3, cameraRoll: 2, disk: 1 },
03-11 16:30:22.764 17169 17200 I ReactNativeJS: Aspect: { fill: 0, stretch: 2, fit: 1 },
03-11 16:30:22.764 17169 17200 I ReactNativeJS: Type: { front: 1, back: 2 } }
if not extending from SplashActivity and _undefined_ if extending.
It seems the native module system is somehow messed up when using SplashActivity.
Tested this with Android Emulator: Nexus_5X_API_27(AVD) - 8.1.0
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you believe the issue is still relevant, please test on the latest version and report back. Thank you for your contributions.
1+
same , i have error
E/unknown:ReactNative: Exception in native call
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.boilerplate/com.reactnativenavigation.controllers.NavigationActivity}; have you declared this activity in your AndroidManifest.xml?
1+ Same error here as well
Why no one from RNCamera or RNN are answering? this still an issue, CameraManager some times initialized correctly and the app responds with the port of the native modules but some other times it fails to initialized and crash the app.
Installing and re installing react native camera and then link it via manual or via react-native link still doesnt work.
Any ideas?
I'm experiencing the same issue. I've tried a couple different ways of installing and gradle configuration and I still can't get these two to play nice.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you believe the issue is still relevant, please test on the latest version and report back. Thank you for your contributions.
The issue has been closed for inactivity.
I'm facing this same problem.
I haven't tested on iOS.
Ok, solved.
On MainApplication.java, after you extend NavigationApplication, you have to add a getPackages method. I had forgotten to add the content from the old getPackages, which included new RNCameraPackage()
Most helpful comment
I'm experiencing the same issue. I've tried a couple different ways of installing and gradle configuration and I still can't get these two to play nice.