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'
}
}
allprojects {
repositories {
google()
jcenter()
}
project.ext {
defaultBuildToolsVersion="29.0.2" //String
defaultMinSdkVersion=22 //
defaultTargetSdkVersion=29 //
defaultCompileSdkVersion=29 //
}
}
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
/**
* Fetches the user's defined Kotlin Version from config.xml.
* If the version is not set or invalid, it will default to the ${defaultGradlePluginKotlinVersion}
*/
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'
Ionic Framework Info:
Ionic CLI : 6.7.0 (C:\Program Files\nodejs\node_modules\@ionic\cli)
Ionic Framework : @ionic/angular 5.3.1
@angular-devkit/build-angular : 0.1000.6
@angular-devkit/schematics : 10.0.6
@angular/cli : 10.0.6
@ionic/angular-toolkit : 2.3.0
Capacitor:
Capacitor CLI : 2.4.0
@capacitor/core : 2.4.0
Cordova:
Cordova CLI : 9.0.0 ([email protected])
Cordova Platforms : android 9.0.0
Cordova Plugins : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.2.1, (and 12 other plugins)
Utility:
cordova-res : not installed
native-run (update available: 1.3.0) : 1.0.0
System:
NodeJS : v14.15.1 (C:\Program Files\nodejs\node.exe)
npm : 6.14.9
OS : Windows 10
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.
Thanks a lot!