4

我正在尝试将 react-native-maps 添加到我的 react-native-firebase 入门应用程序中。在我尝试添加 react-native-maps 之前,我没有收到错误。以下是我完全按照他们的指示后的代码。我尝试将地图依赖项更改为 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'
4

2 回答 2

2

测试后更新并找到正确的解决方案..

好的,所以我现在只使用 Firebase 进行云消息传递,所以我的解决方案可能比您的解决方案简单得多。基本上我从添加 firebase-core 开始,它抱怨 play-services-measurement-base 在不同版本中被多次请求。所以我从 firebase-core 依赖项中排除了它并独立添加了它,强制它被请求的版本。然后它抱怨我遵循与上面相同的模式的firebase-analytics,但是,它又给了我第一个错误,用于play-services-measurement-base。我必须从 firebase-analytics 中排除它才能继续。

接下来,我添加了 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'
    }
}

我还为 react-native-maps 设置了项目范围的属性,以便在他们的 Android 文档中提到https://github.com/react-community/react-native-maps/blob/master/docs/installation.md#android

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

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

希望这可以帮助!祝你好运

于 2018-06-13T00:26:57.110 回答
1

我终于弄明白了,我觉得花了这么长时间才弄明白真的很愚蠢。我所要做的就是改变它,play-services-base而且play-services-map versions to 15.0.1. 我还必须build在改变它之后清洁它。

感谢您对它进行调查,basudz,您的解决方案超出了我的想象。我并不像Android我应该熟悉的那样熟悉。我正在努力熟悉它,它是个婊子。

于 2018-07-30T05:11:26.050 回答