简体   繁体   中英

Flutter Firestore doesn't retrieve any data in released android apk

I have tried to develop a flutter application that uses firestore and firebase auth for authentication.

In debug mode, when I test the application it retrieves data from firestore and show it. and firebase auth also work properly.

But in release mode, Firestore doesn't retrieve any data and shows an error given below. but Firebase auth perfectly works in release mode application.

I catch the error in release mode by using android studio build variant feature.

Thank you for reading.

E/io.grpc.internal.S1: [Channel<1>: (firestore.googleapis.com)] Uncaught exception in the SynchronizationContext. Panic!
    java.lang.ExceptionInInitializerError
        at m1.j.Q(Unknown Source:22)
        at io.grpc.internal.D.Q(Unknown Source:4)
        at io.grpc.internal.k1.A(:3)
        at io.grpc.internal.a1.run(:2)
        at k1.t1.a(Unknown Source:24)
        at k1.t1.execute(:2)
        at io.grpc.internal.K1.b(Unknown Source:9)
        at io.grpc.internal.u0.a(:10)
        at io.grpc.internal.u0.run(Unknown Source:38)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:919)
     Caused by: java.lang.RuntimeException: java.lang.NoSuchMethodException: o1.a.values []
        at java.lang.Enum.enumValues(Enum.java:270)
        at java.lang.Enum.access$000(Enum.java:61)
        at java.lang.Enum$1.create(Enum.java:277)
        at java.lang.Enum$1.create(Enum.java:275)
        at libcore.util.BasicLruCache.get(BasicLruCache.java:63)
        at java.lang.Enum.getSharedConstants(Enum.java:289)
        at java.lang.Class.getEnumConstantsShared(Class.java:2428)
        at java.util.EnumMap.getKeyUniverse(EnumMap.java:755)
        at java.util.EnumMap.<init>(EnumMap.java:138)
        at m1.v.<clinit>(:1)
        at m1.j.Q(Unknown Source:22) 
        at io.grpc.internal.D.Q(Unknown Source:4) 
        at io.grpc.internal.k1.A(:3) 
        at io.grpc.internal.a1.run(:2) 
        at k1.t1.a(Unknown Source:24) 
        at k1.t1.execute(:2) 
        at io.grpc.internal.K1.b(Unknown Source:9) 
        at io.grpc.internal.u0.a(:10) 
        at io.grpc.internal.u0.run(Unknown Source:38) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
        at java.lang.Thread.run(Thread.java:919) 
     Caused by: java.lang.NoSuchMethodException: o1.a.values []
        at java.lang.Class.getMethod(Class.java:2072)
        at java.lang.Class.getDeclaredMethod(Class.java:2050)
        at java.lang.Enum.enumValues(Enum.java:267)

W/Firestore: (23.0.1) [Z]: (3a36b20) Stream closed with status: o1{code=INTERNAL, description=Panic! This is a bug!, cause=java.lang.ExceptionInInitializerError
        at m1.j.Q(Unknown Source:22)
        at io.grpc.internal.D.Q(Unknown Source:4)
        at io.grpc.internal.k1.A(:3)
        at io.grpc.internal.a1.run(:2)
        at k1.t1.a(Unknown Source:24)
        at k1.t1.execute(:2)
        at io.grpc.internal.K1.b(Unknown Source:9)
        at io.grpc.internal.u0.a(:10)
        at io.grpc.internal.u0.run(Unknown Source:38) 

This is a common error with Firestore. The problem is with the minifyEnabled and shrinkResources fields in android/app/build.gradle .

You should be able to solve this by changing your release build type in android/app/build.gradle as follows:

buildTypes {
...
    release {
        ...
        signingConfig signingConfigs.release
        minifyEnabled false
        shrinkResources false
    }
}  

Of course this is not an ideal "solution" as the app-size becomes larger. But the Firebase team says they can't help because we use flutter which isn't officially supported...

Here are related issues: https://github.com/FirebaseExtended/flutterfire/discussions/5708#discussioncomment-925997
https://github.com/FirebaseExtended/flutterfire/issues/1412

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM