Flutter应用程序仅在发布模式下崩溃

时间:2019-12-11 14:22:56

标签: android firebase flutter google-cloud-firestore

我有一个Flutter应用程序,当通过Android Studio在调试模式下安装时,运行完全正常;在发布模式下,登录后崩溃。我从Play控制台中获取了崩溃报告:

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:873)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loop (Looper.java:198)
  at android.app.ActivityThread.main (ActivityThread.java:6732)
  at java.lang.reflect.Method.invoke (Method.java)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:493)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:858)
Caused by: java.lang.AbstractMethodError: 
  at com.google.protobuf.GeneratedMessageLite.a (GeneratedMessageLite.java:1319)
  at com.google.firestore.v1.Target$DocumentsTarget.ensureDocumentsIsMutable (Target.java:145)
  at com.google.firestore.v1.Target$DocumentsTarget.addDocuments (Target.java:181)
  at com.google.firestore.v1.Target$DocumentsTarget.a (Target.java:78)
  at com.google.firestore.v1.Target$DocumentsTarget$Builder.addDocuments (Target.java:428)
  at com.google.firebase.firestore.remote.RemoteSerializer.a (RemoteSerializer.java:699)
  at com.google.firebase.firestore.local.LocalSerializer.a (LocalSerializer.java:213)
  at com.google.firebase.firestore.local.SQLiteQueryCache.c (SQLiteQueryCache.java:103)
  at com.google.firebase.firestore.local.SQLiteQueryCache.a (SQLiteQueryCache.java:142)
  at com.google.firebase.firestore.local.LocalStore.a (LocalStore.java:530)
  at com.google.firebase.firestore.local.LocalStore$$Lambda$8.run (LocalStore.java:6)
  at com.google.firebase.firestore.local.SQLitePersistence.a (SQLitePersistence.java:180)
  at com.google.firebase.firestore.local.LocalStore.a (LocalStore.java:520)
  at com.google.firebase.firestore.core.SyncEngine.a (SyncEngine.java:178)
  at com.google.firebase.firestore.core.EventManager.a (EventManager.java:91)
  at com.google.firebase.firestore.core.FirestoreClient.b (FirestoreClient.java:152)
  at com.google.firebase.firestore.core.FirestoreClient$$Lambda$6.run (FirestoreClient.java:4)
  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:458)
  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:1167)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:641)
  at com.google.firebase.firestore.util.AsyncQueue$DelayedStartFactory.run (AsyncQueue.java:205)
  at java.lang.Thread.run (Thread.java:764)

我的pubsec.yaml依赖项是:

version: 1.0.0+3

environment:
  sdk: ">=2.1.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^0.1.2
  shared_preferences: ^0.4.3
  connectivity: ^0.4.3+1
  firebase_auth: ^0.11.1+6
  geolocator: ^5.0.1
  cloud_firestore: ^0.12.11
  flutter_blue: 0.6.2
  intl: ^0.15.8
  random_string: ^0.0.2
  flutter_datetime_picker: ^1.2.4
  permission_handler: ^3.1.0

dev_dependencies:
  flutter_test:
    sdk: flutter

  font_awesome_flutter: ^8.0.1

我尝试更新cloud_firestore插件,但是由于我处于稳定通道中,所以我无法升级到版本0.13.0 + 1,因为最低Flutter版本为1.10.0,并且我处于版本中

Flutter 1.9.1+hotfix.6 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 68587a0916 (3 months ago) • 2019-09-13 19:46:58 -0700
Engine • revision b863200c37
Tools • Dart 2.5.0

此外,cloud_firestore 0.13.0出现以下错误:

Invalid argument(s): Minimum version ("0.13.0") must be less than maximum ("0.13.0-0").

























package:pub_semver/src/version_range.dart 67:7                          new VersionRange
package:pub/src/solver/reformat_ranges.dart 61:27                       _reformatTerm
package:pub/src/solver/reformat_ranges.dart 39:26                       reformatRanges.<fn>
dart:_internal                                                          ListIterable.toList
package:pub/src/solver/reformat_ranges.dart 40:12                       reformatRanges
package:pub/src/solver/reformat_ranges.dart 34:9                        reformatRanges
package:pub/src/solver/reformat_ranges.dart 33:27                       reformatRanges
package:pub/src/solver/version_solver.dart 308:24                       VersionSolver._resolveConflict
package:pub/src/solver/version_solver.dart 131:27                       VersionSolver._propagate
package:pub/src/solver/version_solver.dart 96:9                         VersionSolver.solve
===== asynchronous gap ===========================
package:pub/src/solver.dart 35:10                                       resolveVersions.<fn>
package:pub/src/log.dart 378:18                                         progress
package:pub/src/solver.dart 32:10                                       resolveVersions
package:pub/src/entrypoint.dart 203:24                                  Entrypoint.acquireDependencies
===== asynchronous gap ===========================
package:pub/src/command/get.dart 41:23                                  GetCommand.run
package:args/command_runner.dart 194:27                                 CommandRunner.runCommand
===== asynchronous gap ===========================
package:pub/src/command_runner.dart 171:39                              PubCommandRunner.runCommand.<fn>
dart:async                                                              new Future.sync
package:pub/src/utils.dart 109:12                                       captureErrors.<fn>
dart:async                                                              runZoned
package:pub/src/utils.dart 126:5                                        captureErrors


package:pub/src/command_runner.dart 171:13                              PubCommandRunner.runCommand
===== asynchronous gap ===========================
package:pub/src/command_runner.dart 119:11                              PubCommandRunner.run
===== asynchronous gap ===========================
/b/s/w/ir/k/src/third_party/dart/third_party/pkg/pub/bin/pub.dart 8:22  main




This is an unexpected error. Please run


    pub --trace '--verbosity=warning' get --no-precompile




and include the logs in an issue on https://github.com/dart-lang/pub/issues/new
pub get failed (1)

4 个答案:

答案 0 :(得分:2)

解决此问题

flutter build apk --no-shrink

答案 1 :(得分:0)

尝试在命令行上运行flutter pub cache repair并从Android Studio同步gradle文件。

之后,您可能会遇到Android X错误。只要您愿意,便可以迁移到Android X

迁移到Android X:https://flutter.dev/docs/development/androidx-migration

答案 2 :(得分:0)

因此,我通过更改为Flutter主频道并升级为:

Flutter 1.13.1-pre.94 • channel master • https://github.com/flutter/flutter.git
Framework • revision 36e599eb5d (2 days ago) • 2019-12-11 07:27:13 +0100
Engine • revision 12bf95fd49
Tools • Dart 2.7.0 (build 2.7.0-dev.2.1 8b8894648f)

此外,由于我发现这是导致崩溃的插件,因此我将Cloud Firestore升级到了最新版本。

然后我不得不将依赖项从Android> Build.gradle升级到:

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

此外,我将pubsec.yaml中的所有插件升级到了最新版本,并修复了所有重大更改。

此后,先清理干净,然后再构建apk,一切正常。

答案 3 :(得分:0)

您可以使用flutter build apk --no-shrink。会的。但是推荐的方法是更新flutter sdk以及pubspec.yaml文件中使用的依赖项。