Search code examples
flutterdartgoogle-cloud-firestorecrash

Cloud firestore crashes app in APK release mode


Flutter Cloud Firestore is creating an error on my Flutter App, when i execute it on a APK in release mode it just crashes the app and close it. I have AndroidX and everything works fine when i try the app from flutter run --release and i have my device connected. I have this issue for a week and I haven't found a way to solve it.

First I thought it was an issue with the Google Maps Plugin but later I realize that it also happened in other parts of the app where i don't use it but where I used the cloud_firestore library too. So I think there is an issue with this

This is my console when i execute flutter build apk

Gabriels-MacBook-Pro:Safer jumpbotron$ flutter build apk --release
You are building a fat APK that includes binaries for android-arm, android-arm64.
If you are deploying the app to the Play Store, it's recommended to use app bundles or split the APK to reduce the APK size.
    To generate an app bundle, run:
        flutter build appbundle --target-platform android-arm,android-arm64
        Learn more on: https://developer.android.com/guide/app-bundle
    To split the APKs per ABI, run:
        flutter build apk --target-platform android-arm,android-arm64 --split-per-abi
        Learn more on:  https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split
Initializing gradle...                                              1.3s
Resolving dependencies...                                           4.0s
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
Note: /Users/jumpbotron/Documents/programming/installations/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.12.9+2/android/src/main/java/io/flutter/plugins/firebase/cloudfirestore/CloudFirestorePlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.                    
Note: /Users/jumpbotron/Documents/programming/installations/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.12.9+2/android/src/main/java/io/flutter/plugins/firebase/cloudfirestore/CloudFirestorePlugin.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.                      
Note: /Users/jumpbotron/Documents/programming/installations/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity-0.4.3+6/android/src/main/java/io/flutter/plugins/connectivity/ConnectivityPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.                    
Note: /Users/jumpbotron/Documents/programming/installations/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core-0.4.0+6/android/src/main/java/io/flutter/plugins/firebase/core/FirebaseCorePlugin.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.                      
Note: Some input files use unchecked or unsafe operations.              
Note: Recompile with -Xlint:unchecked for details.                      
RRemoved unused resources: Binary resource data reduced from 256KB to 233KB: Removed 8%
Running Gradle task 'assembleRelease'...                                
Running Gradle task 'assembleRelease'... Done                     117.5s
Built build/app/outputs/apk/release/app-release.apk (7.2MB).

Solution

  • I believe that the following lines are pointing the issue.

    Resolving dependencies...                                           4.0s
    registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
    registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
    registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
    

    Deprecation is not an error, is a warning. In this case it is warning you that this feature will be removed eventually.

    This is a known issue and according to this conversation it is already fixed

    You may also find this answer really helpful as it explains the cause of the problem.