错误:无法为参数找到方法platform()-React Native-Firebase [英] ERROR: Could not find method platform() for arguments - React Native - Firebase

查看:62
本文介绍了错误:无法为参数找到方法platform()-React Native-Firebase的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

react-native-firebase的官方文档之后,有人遇到过此问题吗?

Has anyone faced this issue following the official documentation for react-native-firebase?

ERROR: Could not find method platform() for arguments [com.google.firebase:firebase-bom:21.1.0] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Open File

在编辑两个build.gradle文件并在Android Studio弹出窗口上单击sync之后,会发生这种情况.我认为是因为存在gradle问题.

This happens after editing the two build.gradle files and clicking sync on the Android Studio popup. I think it is there because of a gradle issue.

欢迎任何帮助.但是找不到类似的问题.

Any help is welcome. Could not find a similar issue though.

根据Gabriele Mariotti的要求,编辑了包含两个build.gradle文件的问题.

Edited question with the two build.gradle files as per the request by Gabriele Mariotti.

这是build.gradle文件的内容.

buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 23
        compileSdkVersion = 28
        targetSdkVersion = 28
        supportLibVersion = "28.0.0"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.google.gms:google-services:4.2.0'
        classpath 'com.android.tools.build:gradle:3.3.1'
    }
}

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

这是app/build.gradle文件的内容.

apply plugin: "com.android.application"

apply from: "../../node_modules/react-native/react.gradle"

android {
    compileSdkVersion rootProject.ext.compileSdkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        applicationId "my.app.id"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 33
        versionName "2.2.2"
        multiDexEnabled true
    }
}

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation 'androidx.multidex:multidex:2.0.1'
    implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation 'com.google.firebase:firebase-core:17.0.0'
}

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

这两个build.gradle文件都根据文档进行了修改.

both build.gradle files are modified according to the documentation.

推荐答案

所以,我认为您正在使用Gradle4.x.我遇到过同样的问题.升级到5.0解决了它: https://docs.gradle.org/current/userguide/upgrading_version_4 .html

So, I think you're using Gradle 4.x. I had the same issue. Upgrading to 5.0 solved it: https://docs.gradle.org/current/userguide/upgrading_version_4.html

这篇关于错误:无法为参数找到方法platform()-React Native-Firebase的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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