Home > Enterprise >  Android Studio build error: Gradle - Could not find platform('com.google.firebase:firebase-bom:
Android Studio build error: Gradle - Could not find platform('com.google.firebase:firebase-bom:

Time:09-02

Caused by: org.gradle.internal.resolve.ModuleVersionNotFoundException: Could not find platform('com.google.firebase:firebase-bom:30.3.1').

It seems to have an issue with getting Firebase BOM 30.3.1 even though it exists here: https://mvnrepository.com/artifact/com.google.firebase/firebase-bom/30.3.1

How do I fix this build error? I have tried changing the version nr in /app/build.gradle to match 30.3.1 instead of 30.3.2 but that doesn't change the error. Also manually editing all files to use the latest version (30.3.2) doesn't help.

/app/build.grade

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

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    defaultConfig {
        applicationId "io.sendnow.sendnow"
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 119
        versionName "1.18.11"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

repositories {
    flatDir{
        dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs'
    }
}

configurations.all {
  resolutionStrategy {
    force "com.google.android.gms:play-services-ads:17.0.0"
    force "com.google.android.gms:play-services-basement:17.0.0"
    force "com.google.android.gms:play-services-gcm:17.0.0"
    force "com.google.android.gms:play-services-analytics:17.0.0"

    force "com.google.android.gms:play-services-location:17.0.0"
    force "com.google.android.gms:play-services-tagmanager:17.0.0"
  }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
    implementation project(':capacitor-android')
    testImplementation "junit:junit:$junitVersion"
    androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
    androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"

  // Import the Firebase BoM
  implementation platform('com.google.firebase:firebase-bom:30.3.2') {
    force = true;
  }

  implementation 'com.google.firebase:firebase-analytics'


  // Add the dependencies for any other desired Firebase products
  // https://firebase.google.com/docs/android/setup#available-libraries
    implementation project(':capacitor-cordova-android-plugins')
}


apply from: 'capacitor.build.gradle'

build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.2.0'
        classpath 'com.google.gms:google-services:4.3.10'

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

apply from: "variables.gradle"

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

capacitor.build.grade

// DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN

android {
  compileOptions {
      sourceCompatibility JavaVersion.VERSION_1_8
      targetCompatibility JavaVersion.VERSION_1_8
  }
}

apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle"
dependencies {
    implementation project(':capacitor-app')
    implementation project(':capacitor-storage')
    implementation "androidx.core:core:1.1.0"
    implementation "androidx.core:core:1.0.0"
    implementation "androidx.core:core:1.6. "
    implementation "platform('com.google.firebase:firebase-bom:30.3.1')"
    implementation "com.google.firebase:firebase-analytics"
    implementation "platform('com.google.firebase:firebase-bom:30.3.1')"
    implementation "com.google.firebase:firebase-messaging"
    implementation "me.leolin:ShortcutBadger:1.1.22@aar"
    implementation "com.android.support:support-v4:27. "
    implementation "com.squareup.okhttp3:okhttp:3.12.0"
}
apply from: "../../node_modules/cordova-android-firebase-gradle-release/cordova-android-firebase-gradle-release.gradle"
apply from: "../../node_modules/cordova-android-play-services-gradle-release/cordova-android-play-services-gradle-release.gradle"
apply from: "../../node_modules/phonegap-plugin-barcodescanner-android12/src/android/barcodescanner.gradle"

if (hasProperty('postBuildExtras')) {
  postBuildExtras()
}

CodePudding user response:

Change this:

    implementation "platform('com.google.firebase:firebase-bom:30.3.1')"
    implementation "com.google.firebase:firebase-analytics"
    implementation "platform('com.google.firebase:firebase-bom:30.3.1')"
    implementation "com.google.firebase:firebase-messaging"

into this:

    implementation platform('com.google.firebase:firebase-bom:30.3.1')
    implementation "com.google.firebase:firebase-analytics"
    implementation "com.google.firebase:firebase-messaging"

platform() is a method inside DependencyHandler class, therefore it shouldn't have any quotations around it.

You can check here:

Platform method documentation

  • Related