💭 Unable to get a successful build with react-native-vision-camera
Question
How do i get a successful build? What kotlin, java, hermes, sdk version are compatible with react-native-vision-camera. I had react-native-camera which worked fine but doesn't work for older devices, especially the front camera. I switched to react-native-vision-camera and i've spent almost two days with no luck.
I'm getting errors like: Task :react-native-vision-camera:compileDebugKotlin
- 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
Task :app:mergeExtDexDebug ERROR:D8: com.android.tools.r8.kotlin.H ERROR:D8: com.android.tools.r8.kotlin.H ERROR:D8: com.android.tools.r8.kotlin.H ERROR:D8: com.android.tools.r8.kotlin.H
- What went wrong: Execution failed for task ':app:mergeExtDexDebug'.
Could not resolve all files for configuration ':app:debugRuntimeClasspath'. Failed to transform camera-extensions-1.5.0-alpha01.aar (androidx.camera:camera-extensions:1.5.0-alpha01) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=23, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-runtime}. > Execution failed for DexingWithClasspathTransform: /Users/segunoyedele/.gradle/caches/transforms-3/651088fbbd46f34ddd1c2fee0e4e41c2/transformed/jetified-camera-extensions-1.5.0-alpha01-runtime.jar. > Error while dexing.
What I tried
I've tried cleaning the build, updating memory size in gradle properties.
android/app/build.gradle: `apply plugin: "com.android.application" apply plugin: "com.facebook.react" apply plugin: 'com.google.gms.google-services'
def projectRoot = rootDir.getAbsoluteFile().getParentFile().getAbsolutePath()
/**
-
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 { entryFile = file(["node", "-e", "require('expo/scripts/resolveAppEntry')", projectRoot, "android", "absolute"].execute(null, rootDir).text.trim()) reactNativeDir = new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsoluteFile() hermesCommand = new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath() + "/sdks/hermesc/%OS-BIN%/hermesc" codegenDir = new File(["node", "--print", "require.resolve('@react-native/codegen/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsoluteFile()
// Use Expo CLI to bundle the app, this ensures the Metro config // works correctly with Expo projects. cliFile = new File(["node", "--print", "require.resolve('@expo/cli')"].execute(null, rootDir).text.trim()) bundleCommand = "export:embed"
/* 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")
/* 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 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.tsx' // 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 Run Proguard on Release builds to minify the Java bytecode. */ def enableProguardInReleaseBuilds = (findProperty('android.enableProguardInReleaseBuilds') ?: false).toBoolean()
/**
- 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.toLocaleStringandString.localeComparethat - 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:+'
android { ndkVersion rootProject.ext.ndkVersion buildToolsVersion rootProject.ext.buildToolsVersion compileSdkVersion rootProject.ext.compileSdkVersion
namespace 'com.raiz.application'
defaultConfig {
applicationId 'com.raiz.application'
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0.6"
buildConfigField("boolean", "REACT_NATIVE_UNSTABLE_USE_RUNTIME_SCHEDULER_ALWAYS", (findProperty("reactNative.unstable_useRuntimeSchedulerAlways") ?: true).toString())
// missingDimensionStrategy 'react-native-camera', 'general'
}
signingConfigs {
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
}
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
shrinkResources (findProperty('android.enableShrinkResourcesInReleaseBuilds')?.toBoolean() ?: false)
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
}
// Apply static values from gradle.properties to the android.packagingOptions
// Accepts values in comma delimited lists, example:
// android.packagingOptions.pickFirsts=/LICENSE,**/picasa.ini
["pickFirsts", "excludes", "merges", "doNotStrip"].each { prop ->
// Split option: 'foo,bar' -> ['foo', 'bar']
def options = (findProperty("android.packagingOptions.$prop") ?: "").split(",");
// Trim all elements in place.
for (i in 0..<options.size()) options[i] = options[i].trim();
// [] - "" is essentially [""].filter(Boolean) removing all empty strings.
options -= ""
if (options.length > 0) {
println "android.packagingOptions.$prop += $options ($options.length)"
// Ex: android.packagingOptions.pickFirsts += '**/SCCS/**'
options.each {
android.packagingOptions[prop] += it
}
}
}
dependencies { // The version of react-native is set by the React Native Gradle Plugin implementation("com.facebook.react:react-android")
def isGifEnabled = (findProperty('expo.gif.enabled') ?: "") == "true";
def isWebpEnabled = (findProperty('expo.webp.enabled') ?: "") == "true";
def isWebpAnimatedEnabled = (findProperty('expo.webp.animated') ?: "") == "true";
def frescoVersion = rootProject.ext.frescoVersion
// If your app supports Android versions before Ice Cream Sandwich (API level 14)
if (isGifEnabled || isWebpEnabled) {
implementation("com.facebook.fresco:fresco:${frescoVersion}")
implementation("com.facebook.fresco:imagepipeline-okhttp3:${frescoVersion}")
}
if (isGifEnabled) {
// For animated gif support
implementation("com.facebook.fresco:animated-gif:${frescoVersion}")
}
if (isWebpEnabled) {
// For webp support
implementation("com.facebook.fresco:webpsupport:${frescoVersion}")
if (isWebpAnimatedEnabled) {
// Animated webp support
implementation("com.facebook.fresco:animated-webp:${frescoVersion}")
}
}
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
}
implementation 'com.google.firebase:firebase-messaging:23.1.2'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.10"
implementation "org.jetbrains.kotlin:kotlin-reflect:1.8.10"
implementation project(':react-native-vision-camera')
}
apply from: new File(["node", "--print", "require.resolve('@react-native-community/cli-platform-android/package.json')"].execute(null, rootDir).text.trim(), "../native_modules.gradle"); applyNativeModulesAppBuildGradle(project) `
android/build.gradle: `// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript { ext { buildToolsVersion = findProperty('android.buildToolsVersion') ?: '34.0.0' minSdkVersion = Integer.parseInt(findProperty('android.minSdkVersion') ?: '23') compileSdkVersion = Integer.parseInt(findProperty('android.compileSdkVersion') ?: '34') targetSdkVersion = Integer.parseInt(findProperty('android.targetSdkVersion') ?: '34') kotlin_version = "1.8.10" frescoVersion = findProperty('expo.frescoVersion') ?: '2.5.0'
// We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
ndkVersion = "26.1.10909125"
}
repositories {
google()
mavenCentral()
maven {
url = uri("https://plugins.gradle.org/m2/")
}
}
dependencies {
classpath('com.android.tools.build:gradle')
classpath('com.google.gms:google-services:4.3.15')
classpath('com.facebook.react:react-native-gradle-plugin')
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.10")
// classpath('com.appcues:appcues-android-sdk:4.0.0') } }
allprojects { repositories { maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url(new File(['node', '--print', "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), '../android')) } maven { // Android JSC is installed from npm url(new File(['node', '--print', "require.resolve('jsc-android/package.json')"].execute(null, rootDir).text.trim(), '../dist')) }
maven {
url "https://zendesk.jfrog.io/artifactory/repo"
}
maven {
url = uri("https://plugins.gradle.org/m2/")
}
// maven {
// // expo-camera bundles a custom com.google.android:cameraview
// url "$rootDir/../node_modules/expo-camera/android/maven"
// }
google()
mavenCentral()
maven { url 'https://www.jitpack.io' }
maven { url "https://appcues.jfrog.io/artifactory/appcues-sdk" }
maven { url "https://plugins.gradle.org/m2/"}
}
}
// apply(plugin = "org.jetbrains.kotlin.android")`
gradle-wrapper.properties:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-all.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Please I need urgent help pls
VisionCamera Version
^4.5.3
Additional information
- [X] I am using Expo
- [X] I have read the Troubleshooting Guide
- [X] I agree to follow this project's Code of Conduct
- [X] I searched for similar questions in the issues page as well as in the discussions page and found none.
Guten Tag, Hans here 🍻
It looks like you're running into some build issues with react-native-vision-camera. However, your question is quite broad and lacks specific details about your environment, like exact versions of React Native, Kotlin, Java, and any relevant logs from your build process.
Please provide more detailed information, including the logs you see during the build. This will help mrousavy understand the issue better. Additionally, consider checking the Troubleshooting Guide again for hints on resolving these types of issues.
If you continue facing issues, consider supporting the project on GitHub Sponsors for more direct assistance!
Note: If you think I made a mistake, please ping
@mrousavyto take a look.
I'm using: "react-native": "0.72.10", and Java: openjdk 17.0.12 2024-07-16 OpenJDK Runtime Environment Homebrew (build 17.0.12+0) OpenJDK 64-Bit Server VM Homebrew (build 17.0.12+0, mixed mode, sharing)
@mrousavy Please can you help please
You created the wrong template. You created a question, when you literally had the chance to create a build error instead.