skip to Main Content

I’m using Flutter to build an apk for my application.

Flutter doctor result:

Flutter is already up to date on channel stable
Flutter 3.10.6 • channel stable • https://github.com/flutter/flutter.git
Framework • revision f468f3366c (8 days ago) • 2023-07-12 15:19:05 -0700
Engine • revision cdbeda788a
Tools • Dart 3.0.6 • DevTools 2.23.1

Recently, the apk build always failed because of this error:

* What went wrong:
Execution failed for task ':app:checkReleaseAarMetadata'.
> Could not resolve all files for configuration ':app:releaseRuntimeClasspath'.
   > Could not find any version that matches com.google.firebase:firebase-sessions:[15.0.0, 16.0.0).
     Versions that do not match: 1.0.0
     Required by:
         project :app > project :firebase_crashlytics > com.google.firebase:firebase-crashlytics:18.4.0

Here are the Firebase packages I’m using:

firebase_analytics: ^10.4.4
firebase_crashlytics: ^3.3.4
firebase_core: ^2.15.0
cloud_firestore: ^4.8.3
firebase_storage: ^11.2.5
firebase_auth: ^4.7.1
cloud_functions: ^4.3.4

Gradle versions:

Android gradle plugin version: 7.4.2
Gradle version: 7.6.2

Please help, because I could not find any solution for this new problem!

Here is the gradle android level:

buildscript {
    ext.kotlin_version = '1.8.22'
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.4.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.15'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.7'
    }
}

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

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

tasks.register("clean", Delete) {
    delete rootProject.buildDir
}

Here is the gradle app level:

buildscript {
    repositories {
        maven { url 'https://plugins.gradle.org/m2/' }
    }
    dependencies {
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.14.0'
    }
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new FileNotFoundException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

android {
    compileSdkVersion 33
    ndkVersion flutter.ndkVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        applicationId "com.myappid.app"
        minSdkVersion 24
        targetSdkVersion 33
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }

    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
            storePassword keystoreProperties['storePassword']
        }
    }

    buildTypes {
        release {
            signingConfig signingConfigs.release
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.google.firebase:firebase-analytics-ktx:21.3.0'
}

2

Answers


  1. Chosen as BEST ANSWER

    The only solution for now is to use older versions of Firebase packages.

    Open Android Studio project terminal

    1. Run "flutter clean" command
    2. Run "pod cache clean --all" command
    3. Run "flutter pub cache clean" command

    (Delete also pubspec.lock and podfile.lock files)

    Now use the Firebase packages you want with these versions in pubspec.yaml:

      firebase_analytics: 10.4.3
      firebase_crashlytics: 3.3.3
      firebase_core: 2.14.0
      cloud_firestore: 4.8.1
      firebase_storage: 11.2.3
      firebase_auth: 4.6.3
      cloud_functions: 4.3.3
    

    Make sure to remove "^" before the package version number.

    1. Run "flutter pub get" command
    2. Run "cd ios" then "pod update" commands

    Done.


  2. After plenty of debugging i come to know that the issue caused by onesignal library simply remove them because in newer version of onesignal it was deprecated for more info please follow below link

    Onesignal link

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search