Flutter应用程序在发布模式下使用Firestore插件时崩溃了

时间:2019-10-12 10:45:37

标签: firebase flutter google-cloud-firestore crash

在调试模式下,一切都完美运行。当我将Flutter版本更新为1.10.x时,它第一次发生,我不记得正确使用了哪个版本。应该是1.7.8,很稳定。为了解决这个问题,我将Flutter降级到1.7.8 + 4,还降级了与Firebase相关的发布包。但是这里仍然有错误。

从gogle播放控制台捕获的相关错误的堆栈跟踪

java.lang.RuntimeException: 
  at com.google.firebase.firestore.util.AsyncQueue.a (AsyncQueue.java:379)
  at com.google.firebase.firestore.util.AsyncQueue$$Lambda$5.run (AsyncQueue.java:2)
  at android.os.Handler.handleCallback (Handler.java:790)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loop (Looper.java:164)
  at android.app.ActivityThread.main (ActivityThread.java:7000)
  at java.lang.reflect.Method.invoke (Method.java)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:441)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1408)
Caused by: java.lang.AbstractMethodError: 
  at com.google.protobuf.GeneratedMessageLite.a (GeneratedMessageLite.java:1319)
  at com.google.firebase.firestore.proto.WriteBatch.s (WriteBatch.java:120)
  at com.google.firebase.firestore.proto.WriteBatch.a (WriteBatch.java:162)
  at com.google.firebase.firestore.proto.WriteBatch.a (WriteBatch.java:15)
  at com.google.firebase.firestore.proto.WriteBatch$Builder.a (WriteBatch.java:835)
  at com.google.firebase.firestore.local.LocalSerializer.a (LocalSerializer.java:172)
  at com.google.firebase.firestore.local.SQLiteMutationQueue.a (SQLiteMutationQueue.java:188)
  at com.google.firebase.firestore.local.LocalStore.a (LocalStore.java:237)
  at com.google.firebase.firestore.local.LocalStore$$Lambda$2.get (LocalStore.java:8)
  at com.google.firebase.firestore.local.SQLitePersistence.a (SQLitePersistence.java:195)
  at com.google.firebase.firestore.local.LocalStore.a (LocalStore.java:201)
  at com.google.firebase.firestore.core.SyncEngine.a (SyncEngine.java:227)
  at com.google.firebase.firestore.core.FirestoreClient.a (FirestoreClient.java:200)
  at com.google.firebase.firestore.core.FirestoreClient$$Lambda$11.run (FirestoreClient.java:6)
  at com.google.firebase.firestore.util.AsyncQueue.a (AsyncQueue.java:311)
  at com.google.firebase.firestore.util.AsyncQueue$$Lambda$4.call (AsyncQueue.java:2)
  at com.google.firebase.firestore.util.AsyncQueue.a (AsyncQueue.java:287)
  at com.google.firebase.firestore.util.AsyncQueue$$Lambda$3.run (AsyncQueue.java:4)
  at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:457)
  at java.util.concurrent.FutureTask.run (FutureTask.java:266)
  at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run             
(ScheduledThreadPoolExecutor.java:301)
  at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1162)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:636)
  at com.google.firebase.firestore.util.AsyncQueue$DelayedStartFactory.run (AsyncQueue.java:205)
  at java.lang.Thread.run (Thread.java:764)

当我在设备上(在Android崩溃报告对话框中)看到错误跟踪时,它提到了Firebase 19.0.0

Flutter Doctor:

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel unknown, v1.7.8+hotfix.4, on Microsoft Windows [Version 10.0.17134.1069], locale en-US)

[√] Android toolchain - develop for Android devices (Android SDK version 29.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Enterprise 2017 15.9.7)
[√] Android Studio (version 3.4)
[√] VS Code, 64-bit edition (version 1.38.1)
[√] Connected device (3 available)

• No issues found!

最终描述的错误提示方案:

  • 使用flutter run --release构建应用程序
  • 应用尝试基本的Firestore调用
      

    Firestore.instance.collection('集合名称').document('docuemnt-id')。get()

  • 应用程序崩溃。

使用flutter build appbudle编译时也会遇到相同的错误

5 个答案:

答案 0 :(得分:3)

这是我梦night中的solution

编辑:

错误

FATAL EXCEPTION: main
Process: com.app.android, PID: 12668
java.lang.RuntimeException: Internal error in Firestore (19.0.0).
    at com.google.firebase.firestore.g.j.a(:379)
    at com.google.firebase.firestore.g.g.run(Unknown Source:2)
    at android.os.Handler.handleCallback(Handler.java:873)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6718)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

要解决此错误,请更新android.enableR8=false中的gradle.properties。您需要添加此行的原因默认值为 true

答案 1 :(得分:1)

我能够通过升级gradle版本来保持android.enableR8 = true。

android / build.gradle

来自:

container_commands:
  .
  . some other commands...
  .
  04_installpycurl:
    command: "source /var/app/venv/staging-LQM1lest/bin/activate && export CPPFLAGS=-I/usr/local/opt/openssl/include && export LDFLAGS=-L/usr/local/opt/openssl/lib && pip install pycurl --global-option='--with-openssl'"

收件人:

classpath 'com.android.tools.build:gradle:3.2.1'

android / gradle / wrapper / gradle-wrapper.properties

来自:

classpath 'com.android.tools.build:gradle:3.5.0'

收件人:

distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip

答案 2 :(得分:0)

我有一个类似的案例(相同的错误),所以我将尽力告诉您发生了什么,也许是你遇到的相同问题。

在我的情况下,我丢失了密钥库,因此我经历了要求新密钥的所有过程,依此类推,之后,我发布了一个新版本,并且应用程序按照您的确切方式崩溃了,经过很多次谷歌和我发现的东西与签名有关(因为可以在调试中使用,但不能在发行版中使用),所以我进入了firebase控制台并再次下载了google-services.json文件,并感到惊讶...该文件具有以前没有的块。

之后,我将使用您在此处提供的命令在设备中进行测试(顺便说一句谢谢!),然后呜呼!可以。

我还更新了控制台中的SHA-1签名密钥,因此也可能有所帮助。 希望我的回复可以帮助您提出一些解决方案。

答案 3 :(得分:0)

https://github.com/flutter/flutter/issues/41576

更改为版本3.4.2,即build.gradle(project)中的com.android.tools.build:gradle:3.4.2对我有用。

答案 4 :(得分:0)

我遇到了同样的问题,import tweepy def download_tweets(): CONSUMER_KEY = "consumer key" CONSUMER_SECRET = "consumer secret" OAUTH_TOKEN = "auth token" OAUTH_TOKEN_SECRET = "auth token secret" auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET) auth.set_access_token(OAUTH_TOKEN, OAUTH_TOKEN_SECRET) api = tweepy.API(auth) tweets_IDs = [434828570574479360, 434828682352672768, 434828730394230784, 434828787793276928, 434828917174992896, 434829014013067265, 434829430746537985, 434829430746537985, 434829552742068224] for id in tweets_IDs: tweet = api.get_status(id) print(tweet) 的以下更改解决了该问题。

build.gradle

参考:https://github.com/FirebaseExtended/flutterfire/issues/1412#issuecomment-570161645

我知道禁用缩小功能不是一个完美的解决方案。但似乎火力基地团队正在努力,并将在以后的更新中解决