在一个本机项目中使用Google Map和FCM [英] Using google map and FCM in one react-native project

查看:117
本文介绍了在一个本机项目中使用Google Map和FCM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在一个反应​​本机项目中使用Google Map和FCM,首先我在项目中添加了FCM,一切正常,但是当我添加Google Map时,遇到了错误:

I want to use google map and FCM in one react native project , first I added FCM in project, everything was okay but when I added google map, I faced an error :

我在Google上搜索了很多,答案很多,我都尝试过,但是没有一个对我有用:例如,

I googled a lot, there are so many answers that I have tried but none of them worked for me for example: https://github.com/firebase/FirebaseUI-Android/issues/1230 , some one help me. I will provide some screen shoots of my project , if u need something else, let me know.

推荐答案


注意:我使用的是最新版本的 react-native (v0.56.0)。

Note: I'm using the latest version of react-native (v0.56.0).

在将这些库一起使用时,我遇到了很多问题,最后我得到了这个配置,通过使用以下配置,我可以成功构建并运行我的项目:

I have faced a lot of issues in using these libraries together and finally I've got this config, by using the configuration below I could build and run my project successfully:

android / build.gradle 文件:

buildscript {
    repositories {
        jcenter()
        google()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.0'
        classpath 'com.google.gms:google-services:3.0.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenLocal()
        google()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
}

subprojects {
    afterEvaluate {project ->
        if (project.hasProperty("android")) {
            android {
                compileSdkVersion 26
                buildToolsVersion "27.0.3"
            }
        }
    }
}

ext {
    buildToolsVersion = "27.0.3"
    minSdkVersion = 16
    compileSdkVersion = 26
    targetSdkVersion = 26
    supportLibVersion = "26.1.0"
    googlePlayServicesVersion = "11.0.2"
    androidMapsUtilsVersion = "0.5+"
}

android / app / build.gradle 文件:

...
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:11.0.2'
    implementation 'com.google.android.gms:play-services-maps:11.0.2'
    implementation 'com.google.android.gms:play-services-analytics:11.0.2'
    implementation project(':react-native-fcm')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation 'com.amplitude:android-sdk:2.13.4'
    implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
    implementation "com.facebook.react:react-native:+"  // From node_modules
}

// 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'

android / gradle / wrapper / gradle-wrapper.properties 文件:

#Tue Aug 01 12:26:47 IRDT 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

此文档对于安装 react-native-maps 非常有用。

这篇关于在一个本机项目中使用Google Map和FCM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆