ERROR: Could not find method platform() for arguments - React Native - Firebase

12,932

Solution 1

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

Solution 2

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

Share:
12,932
buddhiv
Author by

buddhiv

Software Engineer, Graphic Designer, Gamer, Mahindian, University of Moratuwa Undergraduate.

Updated on June 07, 2022

Comments

  • buddhiv
    buddhiv about 2 years

    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.

  • buddhiv
    buddhiv almost 5 years
    Correct! I updated and came here to update the question and saw this answer. I resolved by going into gradle 5.1.1
  • Kevin Vugts
    Kevin Vugts over 4 years
    @buddhiv How have you upgraded the gradle to 5.0?
  • Kevin Vugts
    Kevin Vugts over 4 years
    I can't get it working with react-native-firebase v6
  • buddhiv
    buddhiv over 4 years
    Kevin I followed the docs to update the gradle version. There are plenty examples to do so. You just change the necessary places and Android Studio will take care of the rest. stackoverflow.com/questions/17727645/…