react-native-vision-camera icon indicating copy to clipboard operation
react-native-vision-camera copied to clipboard

🔧 Error compiling VisionCameraProxy.kt in react-native 0.74.0

Open aardvarkk opened this issue 1 year ago • 9 comments

How were you trying to build the app?

yarn android

Full build logs

e: file:///home/user/node_modules/react-native-vision-camera/android/src/main/java/com/mrousavy/camera/frameprocessors/VisionCameraProxy.kt:31:79 This API is provided only for React Native frameworks and not intended for general users. This API can change between minor versions in alignment with React Native frameworks and won't be considered a breaking change.
e: file:///home/user/node_modules/react-native-vision-camera/android/src/main/java/com/mrousavy/camera/frameprocessors/VisionCameraProxy.kt:36:19 This API is provided only for React Native frameworks and not intended for general users. This API can change between minor versions in alignment with React Native frameworks and won't be considered a breaking change.
e: file:///home/user/node_modules/react-native-vision-camera/android/src/main/java/com/mrousavy/camera/frameprocessors/VisionCameraProxy.kt:36:47 This API is provided only for React Native frameworks and not intended for general users. This API can change between minor versions in alignment with React Native frameworks and won't be considered a breaking change.
e: file:///home/user/node_modules/react-native-vision-camera/android/src/main/java/com/mrousavy/camera/frameprocessors/VisionCameraProxy.kt:75:73 This API is provided only for React Native frameworks and not intended for general users. This API can change between minor versions in alignment with React Native frameworks and won't be considered a breaking change. FAILURE: Build failed with an exception. * What went wrong:
Execution failed for task ':react-native-vision-camera:compileDebugKotlin'.

Project dependencies

"dependencies": {
    "@aws-amplify/auth": "^5",
    "@aws-amplify/storage": "^5",
    "@react-native-async-storage/async-storage": "^1.23.1",
    "@tanstack/react-query": "^4",
    "axios": "^1.6.8",
    "i18next": "^23.11.2",
    "immer": "^10.0.4",
    "lottie-react-native": "^6.7.2",
    "moment-timezone": "^0.5.45",
    "phosphor-react-native": "^2.0.0",
    "react": "18.2.0",
    "react-i18next": "^14.1.0",
    "react-native": "0.74.0",
    "react-native-barcode-builder": "^2.0.0",
    "react-native-bluetooth-classic": "^1.73.0-rc.8",
    "react-native-paper": "^5.12.3",
    "react-native-signature-capture": "^0.4.12",
    "react-native-svg": "^15.1.0",
    "react-native-vision-camera": "^4.0.1",
    "rn-fetch-blob": "^0.12.0",
    "uuid": "^9.0.1",
    "zustand": "^4.5.2"
  },

VisionCamera Version

4.0.1

Target platforms

Android

Operating system

Linux

Can you build the VisionCamera Example app?

No, I cannot build the Example app either

Additional information

aardvarkk avatar Apr 22 '24 18:04 aardvarkk

VisionCamera does not yet support react-native 0.74.

I've been working sleeplessy the past few weeks to get VisionCamera 4.0.0 released which contains a full rewrite of the Android codebase and Skia Frame Processors, and now I'm off to a vacation for a week.

For react-native 0.74 I want to migrate VisionCamera to new arch (so TurboModule + Fabric + CodeGen), but this is a huge effort and also I am blocked: I have one prop (frameProcessor) which needs custom JSI conversion - I don't want the jsi::Function to be converted to an RCTDirectEventBlock, but rather to a custom type (RNWorklet). I am not sure if that is supported by CodeGen/Fabric/TurboModules, so currently (for Bridge/Paper) I have a very nasty solution where I inject a global.setFrameProcessor(viewTag, frameProcessor) function. More info: https://github.com/reactwg/react-native-new-architecture/discussions/167#discussioncomment-8938596

Once that is resolved or if facebook can give me any pointers on how I could implement this clean, I could try to migrate VisionCamera to new arch / react-native 0.74. But I don't know when I'm gonna do that.

If someone wants to pay me to get VisionCamera migrated to new arch / react-native 0.74, contact me on https://margelo.io.

mrousavy avatar Apr 22 '24 20:04 mrousavy

Thanks for the quick response! For now I am downgrading back to 0.73.7. Enjoy your vacation!

aardvarkk avatar Apr 22 '24 20:04 aardvarkk

Thanks!

mrousavy avatar Apr 22 '24 21:04 mrousavy

Well deserved rest, thank you for your work !

AlixH avatar Apr 23 '24 07:04 AlixH

see https://github.com/mrousavy/react-native-vision-camera/issues/2614

mrousavy avatar Apr 23 '24 12:04 mrousavy

simply downgrade your react native version with npm install [email protected] from 0.74.0 and it really works 26-04-2024 after downgrade may be you have error like this: Error: Unable to resolve module react-native from D:\AmanPrint\index.js: react-native could not be found within the project or in these directories: node_modules 3 | */ 4 |

5 | import {AppRegistry} from 'react-native'; | ^ 6 | import App from './App'; 7 | import {name as appName} from './app.json';

then follow this step run commond cd android ./gradlew clean cd .. npx react-native start --reset-cache and another terminal npm run android

and it works

usyadav007 avatar Apr 26 '24 09:04 usyadav007

Are there any other temporary solutions besides downgrading?

hengkx avatar May 06 '24 14:05 hengkx

Again, see #2614. react-native 0.74 is simply not yet supported by VisionCamera because it still uses the Bridge for other props that are not Frame Processor related.

If you need this, please sponsor the issue #2614 to accelerate the development of this. Otherwise I don't work on it, since I am still on react-native 0.73 with my apps.

mrousavy avatar May 06 '24 15:05 mrousavy

Workaround: https://github.com/mrousavy/react-native-vision-camera/issues/2851#issuecomment-2099325462

danieloprado avatar May 07 '24 21:05 danieloprado

Hey - this is a duplicate of https://github.com/mrousavy/react-native-vision-camera/issues/2614.

New architecture support (which also implies react-native 0.74 support) is tracked in that issue. If you need this, please sponsor the issue/fund the development of that major refactor/migration by donating to the Polar pool mentioned in the issue above.

Thank you.

mrousavy avatar May 08 '24 10:05 mrousavy

The workaround is fine as a patch btw if you need it to build on RN 74 now.

mrousavy avatar May 08 '24 10:05 mrousavy

The Best Solution is to simply downgrade your react native version otherwise you will stuck in a deep well and will not be able to escape. Just downgrade with npm install [email protected] from 0.74.0 and it really works 21-05-2024 > Just run these commands

  1. cd android
  2. ./gradlew clean
  3. cd ..
  4. npx react-native start --reset-cache
  5. and in another terminal type , npm run android

Alternate Option

  1. type ./android/gradlew clean
  2. npx react-native start --reset-cache
  3. close everthing and type npm run android or npx react-native run-android

It works

BulilKhan77 avatar May 21 '24 04:05 BulilKhan77

so why this information not in the document?

coderjinhui avatar May 22 '24 15:05 coderjinhui

What document? I explained right here that VisionCamera doesn't work with RN 0.74 yet. Also there's a pinned issue about this on top of the issue page.

mrousavy avatar May 22 '24 19:05 mrousavy

I've added the lines for the patch but it still won't work, pls is there any workaround for this

image

GeekyCoder25 avatar May 23 '24 01:05 GeekyCoder25

I've added the lines for the patch but it still won't work, pls is there any workaround for this

image

Remove the + before the @OptIn

danieloprado avatar May 23 '24 07:05 danieloprado