I am using Ionic 5 Framework to develop an Android app and wanted to implement Firebase Could Messaging to it. After I updated two build.gradle files and Sync project with Gradle files, I got the following Error message:
Could not find method implementation() for arguments [DefaultExternalModuleDependency{group=‘com.google.firebase’, name=‘firebase-bom’, version=‘26.1.1’, configuration=‘default’}] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Here are my system information:
Project-level build.gradle (/build.gradle):
buildscript {
ext.kotlin_version = ‘1.3.50’
repositories {
google()
jcenter()
}
dependencies {
classpath ‘com.android.tools.build:gradle:4.0.0’
classpath “org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version”
classpath 'com.google.gms:google-services:4.3.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
//This replaces project.properties w.r.t. build settings
project.ext {
defaultBuildToolsVersion="29.0.2" //String
defaultMinSdkVersion=22 //Integer - Minimum requirement is Android 5.1
defaultTargetSdkVersion=29 //Integer - We ALWAYS target the latest by default
defaultCompileSdkVersion=29 //Integer - We ALWAYS compile with the latest by default
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
App-level build.gradle ( //build.gradle )
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
*if* (cdvHelpers.getConfigPreference('GradlePluginKotlinEnabled', 'false').toBoolean()) {
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
}
buildscript {
apply from: '../CordovaLib/cordova.gradle'
*if* (cdvHelpers.getConfigPreference('GradlePluginKotlinEnabled', 'false').toBoolean()) {
String defaultGradlePluginKotlinVersion = kotlin_version
String gradlePluginKotlinVersion = cdvHelpers.getConfigPreference('GradlePluginKotlinVersion', defaultGradlePluginKotlinVersion)
*if* (!cdvHelpers.isVersionValid(gradlePluginKotlinVersion)) {
println("The defined Kotlin version (${gradlePluginKotlinVersion}) does not appear to be a valid version. Falling back to version: ${defaultGradlePluginKotlinVersion}.")
gradlePluginKotlinVersion = defaultGradlePluginKotlinVersion
}
*// Change the version to be used.*
ext.kotlin_version = gradlePluginKotlinVersion
}
repositories {
mavenCentral()
google()
jcenter()
}
dependencies {
apply from: '../CordovaLib/cordova.gradle'
classpath 'com.android.tools.build:gradle:4.0.0'
implementation platform('com.google.firebase:firebase-bom:26.1.1')
implementation 'com.google.firebase:firebase-messaging-ktx'
*if* (cdvHelpers.getConfigPreference('GradlePluginKotlinEnabled', 'false').toBoolean()) {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
*if* (cdvHelpers.getConfigPreference('GradlePluginGoogleServicesEnabled', 'false').toBoolean()) {
String defaultGradlePluginGoogleServicesVersion = '4.2.0'
String gradlePluginGoogleServicesVersion = cdvHelpers.getConfigPreference('GradlePluginGoogleServicesVersion', defaultGradlePluginGoogleServicesVersion)
*if* (!cdvHelpers.isVersionValid(gradlePluginGoogleServicesVersion)) {
println("The defined Google Services plugin version (${gradlePluginGoogleServicesVersion}) does not appear to be a valid version. Falling back to version: ${defaultGradlePluginGoogleServicesVersion}.")
gradlePluginGoogleServicesVersion = defaultGradlePluginGoogleServicesVersion
}
*// Create the Google Services classpath and set it.*
String gradlePluginGoogleServicesClassPath = "com.google.gms:google-services:${gradlePluginGoogleServicesVersion}"
println "Adding classpath: ${gradlePluginGoogleServicesClassPath}"
classpath gradlePluginGoogleServicesClassPath
}
}
}
*// Allow plugins to declare Maven dependencies via build-extras.gradle.*
allprojects {
repositories {
mavenCentral()
jcenter()
}
Gradle Version:
Gradle 6.1.1
------------------------------------------------------------
Build time: 2020-01-24 22:30:24 UTC
Revision: a8c3750babb99d1894378073499d6716a1a1fa5d
Kotlin: 1.3.61
Groovy: 2.5.8
Ant: Apache Ant(TM) version 1.10.7 compiled on September 1 2019
JVM: 1.8.0_271 (Oracle Corporation 25.271-b09)
OS: Windows 10 10.0 amd64
I have tried gradle version 6.3, 6.5, 6.7.1 and got the same kind error message.
Thank you for your help!