Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React-native-camera error when compiling android

I tried to upgrade my react native project to the newest version (0.59.2). Unfortunately, now when trying to run react-native run-android im getting this error:

Could not determine the dependencies of task ':app:preDebugBuild'. > Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'. > Could not resolve project :react-native-camera.  Required by:      project :app   > Cannot choose between the following variants of project :react-native-camera:       - generalDebugRuntimeElements       - mlkitDebugRuntimeElements     All of them match the consumer attributes:       - Variant 'generalDebugRuntimeElements':           - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.           - Found com.android.build.api.attributes.VariantAttr 'generalDebug' but wasn't required.           - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.           - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.           - Found react-native-camera 'general' but wasn't required.       - Variant 'mlkitDebugRuntimeElements':           - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.           - Found com.android.build.api.attributes.VariantAttr 'mlkitDebug' but wasn't required.           - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'.           - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'.           - Found react-native-camera 'mlkit' but wasn't required. 

I have already tried to create a new project however this results in the same error. Reinstalling the node modules didn't help either. On iOS it works fine.

like image 961
Kape Avatar asked Mar 31 '19 15:03

Kape


2 Answers

Insert the following lines in android/app/build.gradle

android {   ...   defaultConfig {     ...     missingDimensionStrategy 'react-native-camera', 'general' <-- insert this line   } } 
like image 142
Kape Avatar answered Sep 28 '22 11:09

Kape


Please insert the following line in android/app/build.gradle inside defaultConfig block either

missingDimensionStrategy 'react-native-camera', 'general' 

or

missingDimensionStrategy 'react-native-camera', 'mlkit' 

Add jitpack to android/build.gradle

allprojects {     repositories {         maven { url "https://jitpack.io" }         maven { url "https://maven.google.com" }     } } 

Complete guide

Could not resolve project :react-native-camera. on Android

like image 45
AbolfazlR Avatar answered Sep 28 '22 12:09

AbolfazlR