Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ERROR: Could not find method platform() for arguments - 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

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.

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

This is the build.gradle file contents.

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"
        }
    }
}

This is the app/build.gradle file contents.

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'

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

like image 692
buddhiv Avatar asked Aug 02 '19 15:08

buddhiv


2 Answers

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

like image 173
philals Avatar answered Sep 19 '22 14:09

philals


Solution: put in android/gradle/wrapper/gradle-wrapper.properties:

distributionUrl=https://services.gradle.org/distributions/gradle-5.4.1-all.zip

Follow this link: https://github.com/FirebaseExtended/flutterfire/issues/3287

like image 26
rohit Avatar answered Sep 18 '22 14:09

rohit