Search code examples
react-nativekotlingradlecamera

React native camera package causing build to fail


Unable to find much info on this.

We have a standard React-native CLI project. Versions

  • React: 18.2.0
  • ReactNative: 0.71.1

None of the configuration files have been edited from default as far as i'm aware.

We have added the following npm package to access and manage camera usage npm install react-native-vision-camera

Without importing the package anywhere in the app. The build is now failing with the following outputs.enter image description here

I've tried various npm camera packages, they have all suffered similar issues. If I uninstall the package. The app builds fine again.

Any ideas what i'm doing wrong?


Solution

  • You need to tell this package to use the correct Kotlin version. Try to add the following lines to your android/build.gradle file:

    buildscript {
        ext {
            buildToolsVersion = "33.0.0"
            minSdkVersion = 23
            compileSdkVersion = 33
            targetSdkVersion = 33
            // For @react-native-community/netinfo package
            androidXCore = "1.0.2"
            // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
            ndkVersion = "23.1.7779620"
    
            kotlin_version = '1.6.20'    // <-- Add this
            kotlinVersion = '1.6.20'     // <-- Add this
        }
        ...
        ...
        ...