mrousavy / react-native-vision-camera

📸 A powerful, high-performance React Native Camera library.
https://react-native-vision-camera.com
MIT License
7.26k stars 1.06k forks source link

🐛 Android & RN 0.71.1: Error at CMakeLists.txt:19 (find_package): Could not find a package configuration file provided by "fbjni" with any of the following names: fbjniConfig.cmake fbjni-config.cmake #1454

Closed anagovitsyn closed 1 year ago

anagovitsyn commented 1 year ago

What were you trying to do?

I wanted to use react-native-vision-camera using react-native 0.71.1 (after upgrading from 0.68)

Reproduceable Code

No response

What happened instead?

Error while building Vision Camera referencing /....../node_modules/react-native-vision-camera/android CMake Error at CMakeLists.txt:19 saying: CMake Error at CMakeLists.txt:19 (find_package): Could not find a package configuration file provided by "fbjni" with any of the following names:

fbjniConfig.cmake
fbjni-config.cmake

Add the installation prefix of "fbjni" to CMAKE_PREFIX_PATH or set "fbjni_DIR" to a directory containing one of the above files. If "fbjni" provides a separate development package or SDK, be sure it has been installed.

Relevant log output

[CXX1429] error when building with cmake using /Users/asnagovits/Downloads/trash/ProjectName71/node_modules/react-native-vision-camera/android/CMakeLists.txt: -- Android: Targeting API '21' with architecture 'x86', ABI 'x86', and processor 'i686'
-- Android: Selected unified Clang toolchain
-- The C compiler identification is Clang 14.0.1
-- The CXX compiler identification is Clang 14.0.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Users/asnagovits/Library/Android/sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Users/asnagovits/Library/Android/sdk/ndk/24.0.8215888/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring incomplete, errors occurred!
See also "/Users/asnagovits/Downloads/trash/ProjectName71/node_modules/react-native-vision-camera/android/.cxx/Debug/h4m5t754/x86/CMakeFiles/CMakeOutput.log".

C++ build system [configure] failed while executing:
    /Users/asnagovits/Library/Android/sdk/cmake/3.22.1/bin/cmake \
      -H/Users/asnagovits/Downloads/trash/ProjectName71/node_modules/react-native-vision-camera/android \
      -DCMAKE_SYSTEM_NAME=Android \
      -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
      -DCMAKE_SYSTEM_VERSION=21 \
      -DANDROID_PLATFORM=android-21 \
      -DANDROID_ABI=x86 \
      -DCMAKE_ANDROID_ARCH_ABI=x86 \
      -DANDROID_NDK=/Users/asnagovits/Library/Android/sdk/ndk/24.0.8215888 \
      -DCMAKE_ANDROID_NDK=/Users/asnagovits/Library/Android/sdk/ndk/24.0.8215888 \
      -DCMAKE_TOOLCHAIN_FILE=/Users/asnagovits/Library/Android/sdk/ndk/24.0.8215888/build/cmake/android.toolchain.cmake \
      -DCMAKE_MAKE_PROGRAM=/Users/asnagovits/Library/Android/sdk/cmake/3.22.1/bin/ninja \
      "-DCMAKE_CXX_FLAGS=-fexceptions -frtti -std=c++1y -DONANDROID" \
      -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/Users/asnagovits/Downloads/trash/ProjectName71/node_modules/react-native-vision-camera/android/build/intermediates/cxx/Debug/h4m5t754/obj/x86 \
      -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=/Users/asnagovits/Downloads/trash/ProjectName71/node_modules/react-native-vision-camera/android/build/intermediates/cxx/Debug/h4m5t754/obj/x86 \
      -DCMAKE_BUILD_TYPE=Debug \
      -DCMAKE_FIND_ROOT_PATH=/Users/asnagovits/Downloads/trash/ProjectName71/node_modules/react-native-vision-camera/android/.cxx/Debug/h4m5t754/prefab/x86/prefab \
      -B/Users/asnagovits/Downloads/trash/ProjectName71/node_modules/react-native-vision-camera/android/.cxx/Debug/h4m5t754/x86 \
      -GNinja \
      -DANDROID_STL=c++_shared \
      -DREACT_NATIVE_VERSION=71 \
      -DNODE_MODULES_DIR=/Users/asnagovits/Downloads/trash/ProjectName71/node_modules \
      -DFOR_HERMES=true \
      -DJS_RUNTIME_DIR=/Users/asnagovits/Downloads/trash/ProjectName71/node_modules/react-native/sdks/hermes
  from /Users/asnagovits/Downloads/trash/ProjectName71/node_modules/react-native-vision-camera/android
CMake Error at CMakeLists.txt:19 (find_package):
  Could not find a package configuration file provided by "fbjni" with any of
  the following names:

    fbjniConfig.cmake
    fbjni-config.cmake

  Add the installation prefix of "fbjni" to CMAKE_PREFIX_PATH or set
  "fbjni_DIR" to a directory containing one of the above files.  If "fbjni"
  provides a separate development package or SDK, be sure it has been
  installed.
Unresolved module dependency :react-native-reanimated (:) in :vision-camera-code-scanner (BuildId(buildRoot=/Users/asnagovits/Downloads/trash/ProjectName71/android)). Neither the source set nor the artifact property was populated by the Android Gradle plugin.
Unresolved module dependency :react-native-reanimated (:) in :vision-camera-code-scanner (BuildId(buildRoot=/Users/asnagovits/Downloads/trash/ProjectName71/android)). Neither the source set nor the artifact property was populated by the Android Gradle plugin.
Unresolved module dependency :react-native-reanimated (:) in :vision-camera-code-scanner (BuildId(buildRoot=/Users/asnagovits/Downloads/trash/ProjectName71/android)). Neither the source set nor the artifact property was populated by the Android Gradle plugin.

Device

Android Studio, Mac M1 Pro

VisionCamera Version

2.15.4

Additional information

anagovitsyn commented 1 year ago

project build.gradle:

import org.apache.tools.ant.taskdefs.condition.Os

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        kotlinVersion = '1.5.30'
        buildToolsVersion = "29.0.2"
        buildToolsVersion = "31.0.0"
        minSdkVersion = 24
        compileSdkVersion = 31
        targetSdkVersion = 31
        supportLibVersion = "29.0.2"
        androidXCore = "1.0.2" // <-- Add this. Check versions here: https://developer.android.com/jetpack/androidx/releases/core

        if (System.properties['os.arch'] == "aarch64") {
            // For M1 Users we need to use the NDK 24 which added support for aarch64
            ndkVersion = "24.0.8215888"
        } else {
            // Otherwise we default to the side-by-side NDK version from AGP.
            ndkVersion = "21.4.7075529"
        }
    }
    repositories {
        mavenCentral()
        jcenter()
        google()
    }
    dependencies {
        classpath('com.android.tools.build:gradle:7.4.0')
        classpath("com.facebook.react:react-native-gradle-plugin")
        classpath("de.undercouch:gradle-download-task:4.1.2")
        classpath 'com.google.gms:google-services:4.0.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
        classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlinVersion"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        exclusiveContent {
            // We get React Native's Android binaries exclusively through npm,
            // from a local Maven repo inside node_modules/react-native/.
            // (The use of exclusiveContent prevents looking elsewhere like Maven Central
            // and potentially getting a wrong version.)
            filter {
                includeGroup "com.facebook.react"
            }
            forRepository {
                maven {
                    // NOTE: if you are in a monorepo, you may have "$rootDir/../../../node_modules/react-native/android"
                    url "$rootDir/../node_modules/react-native/android"
                }
            }
        }

        google()
        mavenLocal()

        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }
        maven { url 'https://developer.huawei.com/repo/' }
        mavenCentral {
            // We don't want to fetch react-native from Maven Central as there are
            // older versions over there.
            content {
                excludeGroup "com.facebook.react"
            }
        }

        mavenCentral()
        jcenter()
        maven { url 'https://www.jitpack.io' }
    }
}
anagovitsyn commented 1 year ago

app build.gradle:

apply plugin: "com.android.application"
apply plugin: "com.facebook.react"
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

import com.android.build.OutputFile

/**
 * This is the configuration block to customize your React Native Android app.
 * By default you don't need to apply any configuration, just uncomment the lines you need.
 */
react {
    /* Folders */
    //   The root of your project, i.e. where "package.json" lives. Default is '..'
    // root = file("../")
    //   The folder where the react-native NPM package is. Default is ../node_modules/react-native
    // reactNativeDir = file("../node_modules/react-native")
    //   The folder where the react-native Codegen package is. Default is ../node_modules/react-native-codegen
    // codegenDir = file("../node_modules/react-native-codegen")
    //   The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
    // cliFile = file("../node_modules/react-native/cli.js")

    /* Variants */
    //   The list of variants to that are debuggable. For those we're going to
    //   skip the bundling of the JS bundle and the assets. By default is just 'debug'.
    //   If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
    // debuggableVariants = ["liteDebug", "prodDebug"]

    /* Bundling */
    //   A list containing the node command and its flags. Default is just 'node'.
    // nodeExecutableAndArgs = ["node"]
    //
    //   The command to run when bundling. By default is 'bundle'
    // bundleCommand = "ram-bundle"
    //
    //   The path to the CLI configuration file. Default is empty.
    // bundleConfig = file(../rn-cli.config.js)
    //
    //   The name of the generated asset file containing your JS bundle
    // bundleAssetName = "MyApplication.android.bundle"
    //
    //   The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
    // entryFile = file("../js/MyApplication.android.js")
    //
    //   A list of extra flags to pass to the 'bundle' commands.
    //   See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
    // extraPackagerArgs = []

    /* Hermes Commands */
    //   The hermes compiler command to run. By default it is 'hermesc'
    // hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
    //
    //   The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
    // hermesFlags = ["-O", "-output-source-map"]
}

/**
 * Set this to true to create four separate APKs instead of one,
 * one for each native architecture. This is useful if you don't
 * use App Bundles (https://developer.android.com/guide/app-bundle/)
 * and want to have separate APKs to upload to the Play Store.
 */
def enableSeparateBuildPerCPUArchitecture = false

/**
 * Set this to true to Run Proguard on Release builds to minify the Java bytecode.
 */
def enableProguardInReleaseBuilds = false

/**
 * The preferred build flavor of JavaScriptCore (JSC)
 *
 * For example, to use the international variant, you can use:
 * `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
 *
 * The international variant includes ICU i18n library and necessary data
 * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
 * give correct results when using with locales other than en-US. Note that
 * this variant is about 6MiB larger per architecture than default.
 */
def jscFlavor = 'org.webkit:android-jsc:+'

/**
 * Private function to get the list of Native Architectures you want to build.
 * This reads the value from reactNativeArchitectures in your gradle.properties
 * file and works together with the --active-arch-only flag of react-native run-android.
 */
def reactNativeArchitectures() {
    def value = project.getProperties().get("reactNativeArchitectures")
    return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
}

android {
    ndkVersion rootProject.ext.ndkVersion

    compileSdkVersion rootProject.ext.compileSdkVersion

    namespace "com.projectname71"
    defaultConfig {
        applicationId "com.projectname71"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        compileSdkVersion rootProject.ext.compileSdkVersion
        versionCode 1
        versionName "1.0"

        buildConfigField "String", "CLIENT_ID", "\"GOGYM_test\""
        buildConfigField "String", "CLIENT_SECRET", "\"*******\""
        buildConfigField "String", "REDIRECT_URI", "\"https://gogym.ru/test_redirect\""
        buildConfigField "String", "SDK_CLIENT_NAME", "\"gogym.app\""
    }

//    defaultConfig {
//        applicationId "com.app.gogym"
//        minSdkVersion rootProject.ext.minSdkVersion
//        targetSdkVersion rootProject.ext.targetSdkVersion
//        versionCode 162
//        versionName "2.10.5.01-beta"
//        missingDimensionStrategy 'react-native-camera', 'general'
//        multiDexEnabled true
//        signingConfig signingConfigs.release
//
//
//        buildConfigField "String", "CLIENT_ID", "\"GOGYM_test\""
//        buildConfigField "String", "CLIENT_SECRET", "\"*****\""
//        buildConfigField "String", "REDIRECT_URI", "\"https://gogym.ru/test_redirect\""
//        buildConfigField "String", "SDK_CLIENT_NAME", "\"gogym.app\""
////        buildConfigField "String", "AF_DEV_KEY", "\"${af_dev_key}\""
//
//    }

    signingConfigs {
        debug {
            storeFile file('debug.keystore')
            storePassword 'android'
            keyAlias 'androiddebugkey'
            keyPassword 'android'
        }
        release {
            storeFile file('/Users/sdsolomoni/Desktop/work/frontend-mobile/android/app/keystore.jks')
            keyAlias 'upload'
            storePassword '***'
            keyPassword '***'
            if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) {
                storeFile file(MYAPP_UPLOAD_STORE_FILE)
                storePassword MYAPP_UPLOAD_STORE_PASSWORD
                keyAlias MYAPP_UPLOAD_KEY_ALIAS
                keyPassword MYAPP_UPLOAD_KEY_PASSWORD
            }
        }
    }

    buildTypes {
        debug {
            debuggable true
        }
        release {
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            signingConfig signingConfigs.release
        }
    }
    splits {
        abi {
            reset()
            enable enableSeparateBuildPerCPUArchitecture
            universalApk false  // If true, also generate a universal APK
            include (*reactNativeArchitectures())
        }
    }

    buildFeatures {
        prefab true
    }

    buildTypes {
        debug {
            signingConfig signingConfigs.debug
        }
        release {
            // Caution! In production, you need to generate your own keystore file.
            // see https://reactnative.dev/docs/signed-apk-android.
            signingConfig signingConfigs.debug
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }

    // applicationVariants are e.g. debug, release
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            // For each separate APK per architecture, set a unique version code as described here:
            // https://developer.android.com/studio/build/configure-apk-splits.html
            // Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc.
            def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {  // null for the universal-debug, universal-release variants
                output.versionCodeOverride =
                        defaultConfig.versionCode * 1000 + versionCodes.get(abi)
            }

        }
    }

    packagingOptions {
       pickFirst 'lib/x86/libc++_shared.so'
       pickFirst 'lib/x86_64/libjsc.so'
       pickFirst 'lib/arm64-v8a/libjsc.so'
       pickFirst 'lib/arm64-v8a/libc++_shared.so'
       pickFirst 'lib/x86_64/libc++_shared.so'
       pickFirst 'lib/armeabi-v7a/libc++_shared.so'
     }

    aaptOptions {
        noCompress "tflite"
    }
}

repositories {
    mavenCentral()
}

dependencies {
    implementation project(':react-native-code-push')
    implementation project(':react-native-radial-gradient')
    implementation project(':@amplitude_react-native')
    implementation project(':@react-native-firebase_messaging')
    implementation project(':@react-native-firebase_app')
    implementation project(':react-native-device-info')
    implementation project(':react-native-rate')
    implementation project(':react-native-safe-area-context')
    implementation project(':react-native-appsflyer')
    implementation project(':react-native-webview')
    implementation project(':react-native-fast-image')
    implementation project(':react-native-gesture-handler')
    implementation project(':react-native-config')
    implementation project(':@gogym_react-native-cloud-payments-sdk')
    implementation project(':react-native-permissions')
    implementation project(':react-native-svg')
    implementation project(':lottie-react-native')
    implementation project(':react-native-version-number')
    implementation project(':react-native-splash-screen')
    implementation project(':react-native-screens')
    implementation project(':react-native-reanimated')
    implementation project(':@react-native-community_geolocation')
    implementation project(':@react-native-community_async-storage')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
    implementation 'com.facebook.soloader:soloader:0.9.0+'
    implementation "androidx.browser:browser:1.3.0"
    implementation 'com.facebook.fresco:fresco:2.0.0'
    implementation 'com.facebook.fresco:animated-gif:2.0.0'
    implementation project(path: ':@react-native-community_netinfo')
    implementation 'com.squareup.okhttp3:okhttp:4.9.2'
    implementation "com.squareup.okhttp3:logging-interceptor:4.9.2"
    implementation "com.squareup.okhttp3:okhttp-urlconnection:4.9.2"
    implementation 'com.appsflyer:oaid:6.2.4'
    implementation 'com.huawei.hms:ads-identifier:3.4.39.302'
    implementation 'ru.mts:pushsdk:1.0.14.8'
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
    implementation 'androidx.work:work-runtime-ktx:2.7.0-alpha05'
    implementation "com.getbouncer:cardscan-ui:2.1.0004"
    implementation "com.getbouncer:scan-payment-full:2.1.0004"
    implementation "com.getbouncer:scan-camerax:2.1.0004"
    implementation "com.getbouncer:tensorflow-lite:2.1.0004"

    // compile project(':react-native-fetch-blob')
    implementation project(':react-native-video')
    implementation "androidx.appcompat:appcompat:1.0.0"
    implementation 'com.google.firebase:firebase-messaging-ktx:22.0.0'

    // The version of react-native is set by the React Native Gradle Plugin
    implementation("com.facebook.react:react-android")

    implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0")
    debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
    debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
        exclude group:'com.squareup.okhttp3', module:'okhttp'
    }

    debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}")
    if (hermesEnabled.toBoolean()) {
        implementation("com.facebook.react:hermes-android")
    } else {
        implementation jscFlavor
    }
}

// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
//task copyDownloadableDepsToLibs(type: Copy) {
//    from configurations.compile
//    into 'libs'
//}

apply plugin: 'com.google.gms.google-services'
googleServices {
    disableVersionCheck = true
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
vatsal-gadhiya-searce commented 1 year ago

Same issue. Any update here?

ziXiong commented 1 year ago

Same issue. Any update here?

myselfuser1 commented 1 year ago

Try this https://www.youtube.com/playlist?list=PLQhQEGkwKZUrempLnmxjt7ZCZJu1W3p2i

realsteel85 commented 1 year ago

Same issue :(

Isihaaaa commented 1 year ago

SAME FUCKING ISSUE :( I love it

anagovitsyn commented 1 year ago

I have finally passed this issue through. Steps to solve:

1) Set kotlinVersion = '1.6.20' in android/build.gradle

2) Comment out com.facebook.react in exclusiveContent in android/build.gradle

// exclusiveContent { // // We get React Native's Android binaries exclusively through npm, // // from a local Maven repo inside node_modules/react-native/. // // (The use of exclusiveContent prevents looking elsewhere like Maven Central // // and potentially getting a wrong version.) // filter { // includeGroup "com.facebook.react" // } // forRepository { // maven { // // NOTE: if you are in a monorepo, you may have "$rootDir/../../../node_modules/react-native/android" // url "$rootDir/../node_modules/react-native/android" // } // } // }

react06 commented 1 year ago

Any Update on this Issue? Any help will be appreciated. Thank you in Advance.

fernandopascoalbr commented 1 month ago

I have finally passed this issue through. Steps to solve:

  1. Set kotlinVersion = '1.6.20' in android/build.gradle
  2. Comment out com.facebook.react in exclusiveContent in android/build.gradle

// exclusiveContent { // // We get React Native's Android binaries exclusively through npm, // // from a local Maven repo inside node_modules/react-native/. // // (The use of exclusiveContent prevents looking elsewhere like Maven Central // // and potentially getting a wrong version.) // filter { // includeGroup "com.facebook.react" // } // forRepository { // maven { // // NOTE: if you are in a monorepo, you may have "$rootDir/../../../node_modules/react-native/android" // url "$rootDir/../node_modules/react-native/android" // } // } // }

Thanks @anagovitsyn , i comment my "exclusiveContent". It`s work for me.