I am trying to run the flutter application on the android studio before now all works perfectly but after I changed my targetSdkVersion to targetSdkVersion 31
I started getting this error that says
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Could not resolve com.google.firebase:firebase-core:25.12.0.
Required by:
project :app
> No cached version of com.google.firebase:firebase-core:25.12.0 available for offline mode.
And google-services.json
is available in my project. My pubspec.yaml
for firebase_message is firebase_messaging: ^7.0.3
, android/build.gradle
dependencies is
buildscript {
ext.kotlin_version = '1.3.61'
repositories {
google()
jcenter()
mavenCentral() // Maven Central repository
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.2.0'
}
``` and my ```app/build.gradle``` dependencies is
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
testImplementation 'junit:junit:4.12'
implementation 'com.google.firebase:firebase-analytics'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.google.firebase:firebase-core:11.0.4'
implementation platform('com.google.firebase:firebase-bom:31.0.2')
}
Thanks, in advance, please let me know if there is any information is needed
I tried to clean the project, pub upgrade, pub get, flutter upgrade, and even tried downloading a new version of firebase_messaging and pasting it inside the project still the same error.
2
Answers
So I was able to solve this by first updating my
firebase_messaging
version inpubspec.yaml
tofirebase_messaging: ^13.0.4
Andandroid/build.gradle
dependencies isAnd and my
app/build.gradle
dependencies isThe above solved the issue for me.
add build.repositories
jcenter()
and to allprojects.repositoriesjcenter()
, in your build.gardle file