12

I've installed both react-native-firebase and react-native-camera. The camera was fine when play-services -vision was stuck at 12.0.1, but I just ran into this error (Error updating property googleVisionBarcodeDetectorEnable) https://github.com/react-native-community/react-native-camera/issues/1844 that requires an upgrade to 15.0.2.

It looks like there are Google Play Services and Firebase conflicts when play-services-vision is bumped up to 15.0.2 from 12.0.1:

Dependency failing: com.google.android.gms:play-services-flags:15.0.1 -> com.google.android.gms:play-services-basement@[
  15.0.1], but play-services-basement version was 16.0.1.

  The following dependencies are project dependencies that are direct or have transitive dependencies that lead to the art
  ifact with the issue.
  -- Project 'app' depends onto com.google.firebase:firebase-messaging@17.3.4
  -- Project 'app' depends onto com.google.android.gms:play-services-base@16.0.1
  -- Project 'app' depends onto com.google.firebase:firebase-core@16.0.6
  -- Project 'app' depends onto com.google.android.gms:play-services-vision@15.0.2

I've tried com.google.android.gms:play-services-vision@16.2.0 but it gave me exceed 64k methods error. Bumping up to 17.0.2 would cause a version conflict from com.google.android.gms:play-services-basement.

Anyone using both react-native-firebase and react-native camera? Can you tell me how to solve this version conflict problem?

Here is the dependencies in android/app/build.gradle

dependencies {

    implementation (project(':react-native-camera')) {
      exclude group: "com.google.android.gms"
      implementation "com.android.support:exifinterface:${rootProject.ext.supportLibVersion}"
      implementation ('com.google.android.gms:play-services-vision:12.0.1') {
        force = true
      }
    }
    implementation project(':react-native-gesture-handler')
    implementation project(':react-native-webview')
    implementation project(':react-native-fast-image')
    implementation project(':react-native-google-signin')
    implementation project(':react-native-firebase')
    implementation 'com.google.firebase:firebase-core:16.0.6'
    implementation ('com.google.android.gms:play-services-base:16.0.1')
    implementation 'com.google.firebase:firebase-messaging:17.3.4'
    implementation('com.crashlytics.sdk.android:crashlytics:2.9.5@aar') {
        transitive = true
    }
    implementation(project(':react-native-google-signin')) {
        exclude group: "com.google.android.gms" // very important
    }
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
    implementation 'com.facebook.react:react-native:+'
    implementation project(':react-native-sqlite-storage')
    implementation 'me.leolin:ShortcutBadger:1.1.21@aar'
    implementation 'com.facebook.fresco:animated-gif:1.10.0'
}

Ext in android/build.gradle

ext {
    buildToolsVersion = "28.0.3"
    minSdkVersion = 19
    compileSdkVersion = 28
    targetSdkVersion = 28
    supportLibVersion = "27.1.1"
}

Package:

"react-native-camera": "^1.6.4",
"react-native-firebase": "^5.1.1",
RedGiant
  • 4,036
  • 6
  • 44
  • 117

4 Answers4

10

You need to update the version of gms:play-services-vision. implementation 'com.google.android.gms:play-services-vision:17.0.2'

Varun
  • 174
  • 5
2

For anyone here after ejecting from Expo (v34) into a react-native project wanting to use firebase, and if you kept using expo-barcode-scanner, the problem lies in it because it's using an older version of play-services-vision.

You have multiple options:

  • If a new Expo SDK is released, use it. I'm sure the vision library will be upgraded.
  • Remove expo-barcode-scanner as a dependency and use another one.
  • Pump the version of the vision library in expo-barcode-scanner lib in node_modules\expo-barcode-scanner\android\build.gradle (discouraged)
Bassel Shmali
  • 197
  • 2
  • 14
  • Thanks, this was my issue. We solved in another way using gradle constraints: https://docs.gradle.org/current/userguide/managing_transitive_dependencies.html – James Cross Nov 04 '19 at 13:54
-1

You need to enable MultiDex because:

total number of methods that can be referenced within a single DEX file to 65,536

and by enable multidex , compiler will put extra methods/funcs in another dex file.

so do these steps:

1- Add MultiDex to build.gradle(Module file):

implementation 'com.android.support:multidex:1.0.3'

2 -Clen & Build the project

3- Add multiDexEnabled =true to the same buil.gradle(Module), inside

      android {  
       .... 
         defaultConfig {
      ...
      multiDexEnabled true
     ...
      } 
     } 

to enable MultiDex

4- Add Application Class to your project &Override Application Class that extend it from MultiDexApplication instead of Application, for example :

 java:   public class MyMultiDexApplication extends MultiDexApplication { ... }
Kotlin :  class MyMultiDexApplication : MultiDexApplication() { override fun onCreate() {
    super.onCreate() } }

5- Add your Application Class name to the AndroidManifest.xml in Application Tag:

<application
        android:name=".MyMultiDexApplication "
        android:icon="@mipmap/ic_logo"
        android:label="@string/app_name"
        >

6-Add dependencies that you need like :

com.google.android.gms:play-services-vision@16.2.0

to build.gradle

7 - Build again and done

Google reference for more info : enter link description here

Hamed Jaliliani
  • 2,177
  • 20
  • 29
-1

My easy fix to avoid this happening when importing modules is

1) npm install 2) run-android / run-ios 3) i get the same message or sometimes no message 4) i go to node_modules/react-native-component-name and find the android/build.gradle file , i change the compileSdkVersion and buildToolsVersion to my version (latest), and , replace all dependencies with a plus

com.google.android.gms:play-services-vision:17.0.2 => com.google.android.gms:play-services-vision:+ That way the module always uses the latest libraries available

ValdaXD
  • 2,795
  • 1
  • 5
  • 23