所有 Firebase 库必须高于或低于 14.0.0(react-native-maps & react-native-firebase)



我正在尝试将 react-native-maps 添加到我的 react-native-firebase 入门应用程序中。 直到我尝试添加反应原生地图,我才收到错误。下面是我完全按照他们的说明进行操作后的代码。 我尝试将地图依赖项更改为 15.0.1 并删除重复的播放服务,但这并没有解决任何问题。 任何帮助或见解都非常感谢!一个多星期以来,我一直在为此苦恼并寻找答案。

dependencies {
implementation project(':react-native-vector-icons')
// react-native-google-signin
implementation(project(':react-native-google-signin')) {
exclude group: "com.google.android.gms"
}
implementation 'com.google.android.gms:play-services-auth:15.0.0'
// react-native-fbsdk
implementation project(':react-native-fbsdk')
implementation(project(':react-native-firebase')) {
transitive = false
}
// RNFirebase required dependencies
implementation "com.google.firebase:firebase-core:15.0.2"
implementation "com.google.android.gms:play-services-base:15.0.0"
// RNFirebase optional dependencies
implementation "com.google.firebase:firebase-auth:15.1.0"
implementation "com.google.firebase:firebase-database:15.0.0"
implementation "com.google.firebase:firebase-firestore:16.0.0"
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:27.0.2"
implementation "com.facebook.react:react-native:+"  // From node_modules
// react-native-maps required dependencies
implementation(project(':react-native-maps')){
exclude group: 'com.google.android.gms', module: 'play-services-base'
exclude group: 'com.google.android.gms', module: 'play-services-maps'
}
implementation 'com.google.android.gms:play-services-base:10.0.1'
implementation 'com.google.android.gms:play-services-maps:10.0.1'
}
// 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'

测试后更新并找到合适的解决方案..

好的,所以我现在只使用 Firebase 进行云消息传递,所以我的解决方案可能比你的简单得多。基本上,我从添加Firebase-core开始,它抱怨在不同版本中多次请求play-services-measurement-base。因此,我将其从 firebase 核心依赖项中排除,独立添加它,强制使用请求的版本。 然后它抱怨火碱分析,我遵循与上面相同的模式,但是,然后它再次给了我第一个错误,用于游戏服务测量基础。我不得不从火碱分析中排除它才能继续。

接下来,我添加了 firebase-messaging ,它给了我与 firebase-iid 依赖项相同的错误,我遵循了之前的模式。

您有更多的Firebase依赖项,因此您可能必须像这样逐一完成。

这是我的依赖项块。

dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+"
implementation project(':react-native-device-info')
implementation project(':react-native-config')
implementation project(':react-native-image-picker')
implementation project(':react-native-sentry')
implementation project(':react-native-vector-icons')
implementation project(':react-native-maps')
implementation project(':react-native-firebase')
implementation "com.google.android.gms:play-services-base:${rootProject.ext.googlePlayServicesVersion}"
implementation ("com.google.android.gms:play-services-measurement-base:15.0.4") {
force = true
}
implementation ("com.google.firebase:firebase-analytics:16.0.0") {
force = true
exclude module: 'play-services-measurement-base'
exclude module: 'firebase-analytics-impl'
}
implementation ("com.google.firebase:firebase-analytics-impl:16.0.0") {
force = true
exclude module: 'play-services-measurement-base'
}
implementation ("com.google.firebase:firebase-iid:16.0.0") {
force = true
}
implementation ('com.google.firebase:firebase-core:16.0.0'){
exclude module: 'play-services-measurement-base'
exclude module: "firebase-analytics"
exclude module: "firebase-analytics-impl"
}
implementation ('com.google.firebase:firebase-messaging:17.0.0'){
exclude module: 'firebase-iid'
}
}

我还为反应原生地图设置了项目范围的属性,以按照他们的 Android 文档中提到的使用 https://github.com/react-community/react-native-maps/blob/master/docs/installation.md#android

哦,我还应该提到,在我的项目级 gradle 构建文件中,我的构建脚本依赖项需要更新。

buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.google.gms:google-services:4.0.1'
}
}

希望这有帮助! 祝你好运

我终于想通了,我觉得花了这么长时间才弄清楚真的很愚蠢。 我所要做的就是更换play-services-baseplay-services-map versions to 15.0.1.更换后还必须清洁build

感谢您调查它 basudz,您的解决方案在我的头上是 wayyyyy。 我对Android没有我应该熟悉的那么熟悉。我试图更熟悉它,这是一个婊子。

最新更新