skip to Main Content

I have a react-native project which I’ve just upgraded to version 0.73 (https://react-native-community.github.io/upgrade-helper/?from=0.72.7&to=0.73.0).

The project was already making use of react-native-vision-camera 3.6.10 for a feature that reads barcodes.

However, when I try to build the Android apk I get the error:

> Task :react-native-vision-camera:compileDebugKotlin
e: file:///Users/user/Documents/project/node_modules/react-native-vision-camera/android/src/main/java/com/mrousavy/camera/CameraDevicesManager.kt:74:3 'hasConstants' overrides nothing
e: file:///Users/user/Documents/project/node_modules/react-native-vision-camera/android/src/main/java/com/mrousavy/camera/frameprocessor/VisionCameraProxy.kt:38:58 Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type JavaScriptContextHolder?

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-vision-camera:compileDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
   > Compilation error. See log for more details

I’ve tried downgrading the kotlin version 1.8.0, to 1.6.20 and 1.7.21, as set in react-native-vision-camera and also mentioned in some comments:
https://github.com/mrousavy/react-native-vision-camera/issues/1012#issuecomment-1665622677

But it didn’t make it… The errors get even worse…
Any ideas how I could fix this? Or how could I find the proper kotlin version?

2

Answers


  1. This isn’t actually an answer, but having suffered through this same issue… the reason I stayed at 0.72.x is because that’s what the react-native-vision-camera demo app is using. Not sure if support goes beyond that point yet.

    Login or Signup to reply.
  2. https://github.com/mrousavy/react-native-vision-camera/issues/2263

    the error

    'hasConstants' overrides nothing
    

    solution https://github.com/mrousavy/react-native-vision-camera/issues/2263#issuecomment-1846827956

    It seems this error emerged following the removal of the hasConstants method in RN, a change that was merged in version, surprise surprise, 0.73. facebook/react-native@bbc3657:

    - public boolean hasConstants() {
    -   return false;
    - }
    

    Simply removing the hasConstants() method resolves the problem:
    package/android/src/main/java/com/mrousavy/camera/CameraDevicesManager.kt:

    - override fun hasConstants(): Boolean = true
    

    ISSUE: https://github.com/mrousavy/react-native-vision-camera/issues/2184
    PR: https://github.com/mrousavy/react-native-vision-camera/pull/2264

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search