invertase / react-native-firebase

🔥 A well-tested feature-rich modular Firebase implementation for React Native. Supports both iOS & Android platforms for all Firebase services.
https://rnfirebase.io
Other
11.63k stars 2.2k forks source link

Cannot find a version of 'com.squareup.okhttp3:okhttp' that satisfies the version constraints #2086

Closed alex-mironov closed 5 years ago

alex-mironov commented 5 years ago

Issue

I'm following the instruction for integration of RN with Firebase. Apparently in the end I'm getting an error when building the app:

Cannot find a version of 'com.squareup.okhttp3:okhttp' that satisfies the version constraints: 
   Dependency path 'getnow:react-native-firebase:unspecified' --> 'com.facebook.react:react-native:0.57.7' --> 'com.squareup.okhttp3:okhttp:3.11.0'
   Dependency path 'getnow:react-native-firebase:unspecified' --> 'com.google.firebase:firebase-functions:16.3.0' --> 'com.squareup.okhttp3:okhttp:3.12.1'
   Dependency path 'getnow:react-native-firebase:unspecified' --> 'com.facebook.react:react-native:0.57.7' --> 'com.facebook.fresco:imagepipeline-okhttp3:1.10.0' --> 'com.squareup.okhttp3:okhttp:3.10.0'
   Dependency path 'getnow:react-native-firebase:unspecified' --> 'com.facebook.react:react-native:0.57.7' --> 'com.squareup.okhttp3:okhttp-urlconnection:3.11.0' --> 'com.squareup.okhttp3:okhttp:3.11.0'
   Constraint path 'getnow:react-native-firebase:unspecified' --> 'com.squareup.okhttp3:okhttp' strictly '3.11.0' because of the following reason: debugRuntimeClasspath uses version 3.11.0
   Constraint path 'getnow:react-native-firebase:unspecified' --> 'com.squareup.okhttp3:okhttp' strictly '3.11.0' because of the following reason: debugRuntimeClasspath uses version 3.11.0
   Constraint path 'getnow:react-native-firebase:unspecified' --> 'com.squareup.okhttp3:okhttp' strictly '3.11.0' because of the following reason: debugRuntimeClasspath uses version 3.11.0

Project Files

Android

android/build.gradle:


...

buildscript {
    ext {
        buildToolsVersion = "27.0.3"
        minSdkVersion = 16
        compileSdkVersion = 27
        targetSdkVersion = 26
        supportLibVersion = "27.1.1"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.2'
        classpath 'com.google.gms:google-services:4.2.0'
    }
}

allprojects {
    repositories {
        mavenLocal()
        google()
        jcenter()
        maven {
            url "$rootDir/../node_modules/react-native/android"
        }
    }
}

android/app/build.gradle:

apply plugin: "com.android.application"

...

dependencies {
    compile project(':react-native-firebase')

...

    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation "com.google.android.gms:play-services-base:16.1.0"
    implementation "com.google.firebase:firebase-core:16.0.8"
}

...

apply plugin: 'com.google.gms.google-services'

Environment

mikehardy commented 5 years ago

This should be solved if you update react-native, it's documented that react-native-firebase 5.3.1 needs at least 0.59.3

mikehardy commented 5 years ago

Though I will admit it was a little difficult to find this - it's in the repo but not on the rnfirebase.io docs

https://github.com/invertase/react-native-firebase/tree/v5.x.x#supported-versions---react-native--firebase

n-sviridenko commented 5 years ago

Just had the same issue.

n-sviridenko commented 5 years ago

@mikehardy btw did you add com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true as well?

mikehardy commented 5 years ago

@n-sviridenko I did not but I haven't had a plugin conflict yet that tickled the bug in the version checker for ranges. I believe code-push does it and that's on my work list just not there yet. That said, there was a comment in the related bug that showed how even for that case you can snipe the specific dependency with a little gradle work. I'd use that solution vs blanket disable which (let's be honest) will be forgotten when it's time to remove it, and is probably useful except for the range-verification bug :-)

alex-mironov commented 5 years ago

hm... I've downgraded to v.5.2.5 but now I'm getting The library com.google.android.gms:play-services-measurement-base is being requested by various other libraries at [[16.0.0,16.0.0]], but resolves to 16.0.5. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.

Screenshot 2019-04-28 21 11 09

@mikehardy does it mean I cannot use previous version of rn-firebase?

alex-mironov commented 5 years ago
Screenshot 2019-04-28 21 15 44
n-sviridenko commented 5 years ago

@alex-mironov put com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true at the end of your build.grandle. Don't see other solutions atm.

n-sviridenko commented 5 years ago

Had The library com.google.firebase:firebase-iid is being requested by various other libraries at [[16.2.0,16.2.0]], but resolves to 16.0.0. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies. before.

mikehardy commented 5 years ago

Don't see other solutions atm

Except...to get to react-native 0.59.5, and fully current on everything - it should work without disabling version check I think? That's a drastic step in other words, I wouldn't do it until you see an error message that states it is looking for a version that is inside the version range it says is not valid. That's the version check bug. Everything else is a version incompatibility and I would not merge it if it were a PR, personally - the checks are supposed to mean something

bluefirepatrick commented 5 years ago

I am getting the exact same issue when following the vanilla instructions for integrating react-native-firebase into a react-native Android project. From what I see here there is no solution for this issue except for disabling version check which @mikehardy does not recommend.

Is there a reason this issue is closed? I am dead in the water and no amount of Gradle wrangling seems to help.

mikehardy commented 5 years ago

It is closed because every person has a different setup, and the issue template asks for your specific information. This was opened by @alex-mironov and I will assume you are not on his team working with his package.json + gradle files? So you may have different versions which you have not posted, which would affect the solution for your different project. You should open a new issue. But be aware that to use all of this tech together you really need to stay current with the versions first.

bluefirepatrick commented 5 years ago

Thanks for the reply, Mike. Your assumptions are correct, I am not on that team.

I will endeavor to upgrade the version of react-native on this legacy project I inherited. It makes me nervous though as it does not seem straight forward and there are 1,001 dependencies in this project that I would rather not mess with if I can avoid it.

rn-diff-purge seems like the way to go I guess. Any words of wisdom?

mikehardy commented 5 years ago

rn-diff-purge is definitely the way to go, it quickly became amazing and then was actually ingested as the built-in react-native-cli of doing upgrades starting with upgrades from 0.59.x. I would just select the diff between your versions and work really really slowly - nothing to it but to do it...

willbrid commented 5 years ago

I had the same issue. I fixed by downgrading to react-native-firebase 5.1.1. And then i encoutered another problem : The number of method references in a .dex file cannot exceed 64K where i fixed it with this link : https://developer.android.com/studio/build/multidex#java

I'm using react-native 0.57.8 with android 7.1 (Nougat) - API 25, gradle-4.10.1

vongohren commented 5 years ago

Dont we all need to upgrade react native to 0.59 now anyway because of the 64 bit google play demand, 1st of August?

akhilaantony111 commented 4 years ago

com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true Is it on the root level or in the app level ?