Friday, 10 September 2021

Flutter: Firestore unavailable error on release mode with minifyEnabled

I have been experiencing a very strange error. I have been developing an app for some time now (3 years ago) with flutter. I migrated the application to Null safety and from that moment the app started to crash in release mode causing the error

[cloud_firestore/unavailable] The service is currently unavailable. This is a most likely a transient condition and may be corrected by retrying with a backoff.

Everything works fine on debug mode.

I have the following configuration in the related files in the apk compilation in release mode.

android/build.gradle

buildscript {
    ext.kotlin_version = '1.4.21'
    repositories {
        google()
        jcenter()
    }

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

allprojects {
    repositories {
        google()
        jcenter()

    }
}
...

android/app/build.gradle

...
android {

    buildTypes {
        release {
            signingConfig signingConfigs.release
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
        }
    }
}
...

proguard-rules.pro

## Flutter wrapper
-keep class io.flutter.app.** { *; }
-keep class io.flutter.plugin.**  { *; }
-keep class io.flutter.util.**  { *; }
-keep class io.flutter.view.**  { *; }
-keep class io.flutter.**  { *; }
-keep class io.flutter.plugins.**  { *; }
-keep class com.google.firebase.** { *; }
-keep class com.revenuecat.purchases.** { *; }
-keep class androidx.lifecycle.DefaultLifecycleObserver
-dontwarn android.**

If I change minifyEnabled false shrinkResources false to Everything works fine on release mod too, but my app size increase by 27%.



from Flutter: Firestore unavailable error on release mode with minifyEnabled

No comments:

Post a Comment