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%.
One thing that may work for you is go back to using proguard instead of R8, it may be a step back but could help you. For that to happen the configuration of the release should look like:
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled true
shrinkResources true
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
And maybe you should add to the build gradle that you don't want to use R8:
android.enableR8=true
Another option would be to look at this file and check for the imports to see if there is maybe a secondary library that you should add to your proguard configuration file: /android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant
You can also check the compilation log to see any errors related to some library (link: https://github.com/flutter/flutter/issues/15100#issuecomment-474687849 )
Have you tried updating to a relatively new version of https://pub.dev/packages/cloud_firestore , eg 2.5.2 currently?
What version are you currently using?
Share your pubspec.yaml, sometimes plugins can conflict too.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.