Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔧 CameraDevicesManager.kt: (10, 47): Unresolved reference: RCTDeviceEventEmitter #2691

Closed
5 tasks done
rodgomesc opened this issue Mar 25, 2024 · 3 comments
Closed
5 tasks done
Labels
🔧 build error Issue is related to building VisionCamera in your project

Comments

@rodgomesc
Copy link
Contributor

How were you trying to build the app?

yarn android

Full build logs

> Task :react-native-vision-camera:compileDebugKotlin FAILED
e: /Users/rodrigogomes/workspace/work/company/monorepo/apps/mobile/node_modules/react-native-vision-camera/android/src/main/java/com/mrousavy/camera/CameraDevicesManager.kt: (10, 47): Unresolved reference: RCTDeviceEventEmitter
e: /Users/rodrigogomes/workspace/work/company/monorepo/apps/mobile/node_modules/react-native-vision-camera/android/src/main/java/com/mrousavy/camera/CameraDevicesManager.kt: (93, 37): Not enough information to infer type variable T
e: /Users/rodrigogomes/workspace/work/company/monorepo/apps/mobile/node_modules/react-native-vision-camera/android/src/main/java/com/mrousavy/camera/CameraDevicesManager.kt: (93, 49): Unresolved reference: RCTDeviceEventEmitter

Project dependencies

"dependencies": {
    "expo": "^48.0.0",
    "react": "18.2.0",
    "react-native": "0.71.13",
    "react-native-reanimated": "3.6.1",
    "react-native-safe-area-context": "^4.4.1",
    "react-native-screens": "3.29.0",
    "react-native-vision-camera": "4.0.0-beta.9",
    "react-native-worklets-core": "0.4.0",
    "vision-camera-resize-plugin": "2.1.1"
  },

VisionCamera Version

4.0.0-beta.9

Target platforms

Android

Operating system

MacOS

Can you build the VisionCamera Example app?

Yes, I can successfully build the Example app here

Additional information

@rodgomesc rodgomesc added the 🔧 build error Issue is related to building VisionCamera in your project label Mar 25, 2024
@rodgomesc
Copy link
Contributor Author

rodgomesc commented Mar 25, 2024

it seems that RCTDeviceEventEmitter interface changed in new react-native versions?

in 4.0.0-beta.9 RCTDeviceEventEmitter is imported from

import com.facebook.react.bridge.ReactContext.RCTDeviceEventEmitter

and in the last stable version 3.9.1 it comes from

import com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter

@rodgomesc
Copy link
Contributor Author

while we discuss a better approach for this if someone is using rn 0.71.x like me this monkey patch should work

diff --git a/node_modules/react-native-vision-camera/android/src/main/java/com/mrousavy/camera/CameraDevicesManager.kt b/node_modules/react-native-vision-camera/android/src/main/java/com/mrousavy/camera/CameraDevicesManager.kt
index 7c7fe5a..bfc8779 100644
--- a/node_modules/react-native-vision-camera/android/src/main/java/com/mrousavy/camera/CameraDevicesManager.kt
+++ b/node_modules/react-native-vision-camera/android/src/main/java/com/mrousavy/camera/CameraDevicesManager.kt
@@ -7,7 +7,7 @@ import androidx.camera.extensions.ExtensionsManager
 import androidx.camera.lifecycle.ProcessCameraProvider
 import com.facebook.react.bridge.Arguments
 import com.facebook.react.bridge.ReactApplicationContext
-import com.facebook.react.bridge.ReactContext.RCTDeviceEventEmitter
+import com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter
 import com.facebook.react.bridge.ReactContextBaseJavaModule
 import com.facebook.react.bridge.ReactMethod
 import com.facebook.react.bridge.ReadableArray

@rodgomesc
Copy link
Contributor Author

oh wait, this still works on the lastest rn versions including the example app in this repo, i'm sending a pr reverting it

import com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔧 build error Issue is related to building VisionCamera in your project
Projects
None yet
Development

No branches or pull requests

1 participant