【问题标题】:Flutter release app Firestore fatal exceptionFlutter 发布应用 Firestore 致命异常
【发布时间】:2021-09-01 15:21:00
【问题描述】:

您好,我的应用在发布模式下遇到一个问题,我一周都无法解决。当我输入 flutter run --release 时,调试模式下一切正常,但出现此错误。可能是什么问题? 生成 sha1 和 sha256 密钥并应用于 firebase。可能是因为互联网许可?但是它初始化了firebase,我现在真的被卡住了。当我从 mac 生成发布 apk 时,我遇到了同样的错误。

颤抖的医生 - v

    C:\Users\Alperen\AndroidStudioProjects\hilmiguneruygulmasi>flutter doctor -v
[√] Flutter (Channel master, 2.3.0-17.0.pre.372, on Microsoft Windows [Version 10.0.19042.1052], locale tr-TR)
    • Flutter version 2.3.0-17.0.pre.372 at C:\src\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision a2336e9ac7 (24 hours ago), 2021-06-15 14:59:04 -0400
    • Engine revision e0011fa561
    • Dart version 2.14.0 (build 2.14.0-211.0.dev)

[!] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    X cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    X Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.

[√] Android Studio (version 4.0)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 51.0.1
    • Dart plugin version 193.7547
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

[√] IntelliJ IDEA Community Edition (version 2020.2)
    • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2020.2
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart

[√] Connected device (1 available)
    • SM G780F (mobile) • RF8NA01VXSL • android-arm64 • Android 11 (API 30)

 Running "flutter pub get" in              1.349ms
    Launching lib\main.dart on SM G780F in release mode...
    Note: C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\advance_pdf_viewer-2.0.0\android\src\main\java\pt\tribeiro\flutter_plugin_pdf_viewer\FlutterPluginPdfViewerPlugin.java uses or ove
    rrides a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    Note: C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_core-1.3.0\android\src\main\java\io\flutter\plugins\firebase\core\FlutterFirebaseCorePlugin.java uses or overrides a depr
    ecated API.
    Note: Recompile with -Xlint:deprecation for details.
    Note: C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-2.2.2\android\src\main\java\io\flutter\plugins\firebase\firestore\FlutterFirebaseFirestorePlugin.java uses or over
    rides a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    Note: C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-2.2.2\android\src\main\java\io\flutter\plugins\firebase\firestore\streamhandler\TransactionStreamHandler.java uses
     unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_storage-8.1.3\android\src\main\java\io\flutter\plugins\firebase\storage\FlutterFirebaseStoragePlugin.java:38: warning: [depreca
    tion] Registrar in PluginRegistry has been deprecated
      public static void registerWith(PluginRegistry.Registrar registrar) {
                                                    ^
    1 warning
    Running Gradle task 'assembleRelease'...                          124,6s
    √  Built build\app\outputs\flutter-apk\app-release.apk (8.0MB).
    Installing build\app\outputs\flutter-apk\app.apk...                 8,5s
    
    Flutter run key commands.
    h List all available interactive commands.
    c Clear the screen
    q Quit (terminate the application on the device).
    E/AndroidRuntime(18581): FATAL EXCEPTION: main
    E/AndroidRuntime(18581): Process: com.yol.hilmiguneruygulmasi, PID: 18581
    E/AndroidRuntime(18581): java.lang.RuntimeException: Internal error in Cloud Firestore (23.0.1).
    E/AndroidRuntime(18581):        at com.google.firebase.firestore.u0.u.m(Unknown Source:19)
    E/AndroidRuntime(18581):        at com.google.firebase.firestore.u0.f.run(Unknown Source:2)
    E/AndroidRuntime(18581):        at android.os.Handler.handleCallback(Handler.java:938)
    E/AndroidRuntime(18581):        at android.os.Handler.dispatchMessage(Handler.java:99)
    E/AndroidRuntime(18581):        at android.os.Looper.loop(Looper.java:246)
    E/AndroidRuntime(18581):        at android.app.ActivityThread.main(ActivityThread.java:8506)
    E/AndroidRuntime(18581):        at java.lang.reflect.Method.invoke(Native Method)
    E/AndroidRuntime(18581):        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
    E/AndroidRuntime(18581):        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
    E/AndroidRuntime(18581): Caused by: java.lang.RuntimeException: java.lang.RuntimeException: Failed to gain exclusive lock to the Cloud Firestore client's offline persistence. This genera
    lly means you are using Cloud Firestore from multiple processes in your app. Keep in mind that multi-process Android apps execute the code in your Application class in all processes, so
    you may need to avoid initializing Cloud Firestore in your Application class. If you are intentionally using Cloud Firestore from multiple processes, you can only enable offline persiste
    nce (that is, call setPersistenceEnabled(true)) in one of them.
    E/AndroidRuntime(18581):        at com.google.firebase.firestore.u0.s.i(Unknown Source:14)
    E/AndroidRuntime(18581):        at com.google.firebase.firestore.u0.d.run(Unknown Source:4)
    E/AndroidRuntime(18581):        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
    E/AndroidRuntime(18581):        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    E/AndroidRuntime(18581):        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
    E/AndroidRuntime(18581):        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    E/AndroidRuntime(18581):        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    E/AndroidRuntime(18581):        at com.google.firebase.firestore.u0.r.run(Unknown Source:15)
    E/AndroidRuntime(18581):        at java.lang.Thread.run(Thread.java:923)
    E/AndroidRuntime(18581): Caused by: java.lang.RuntimeException: Failed to gain exclusive lock to the Cloud Firestore client's offline persistence. This generally means you are using Clou
    d Firestore from multiple processes in your app. Keep in mind that multi-process Android apps execute the code in your Application class in all processes, so you may need to avoid initia
    lizing Cloud Firestore in your Application class. If you are intentionally using Cloud Firestore from multiple processes, you can only enable offline persistence (that is, call setPersis
    tenceEnabled(true)) in one of them.
    E/AndroidRuntime(18581):        at com.google.firebase.firestore.q0.e1.k(Unknown Source:44)
    E/AndroidRuntime(18581):        at com.google.firebase.firestore.p0.i0.i(:1)
    E/AndroidRuntime(18581):        at com.google.firebase.firestore.p0.X.g(Unknown Source:65)
    E/AndroidRuntime(18581):        at com.google.firebase.firestore.p0.X.r(Unknown Source:10)
    E/AndroidRuntime(18581):        at com.google.firebase.firestore.p0.s.run(Unknown Source:8)
    E/AndroidRuntime(18581):        at com.google.firebase.firestore.u0.b.call(lambda:1)
    E/AndroidRuntime(18581):        at com.google.firebase.firestore.u0.s.i(Unknown Source:0)
    E/AndroidRuntime(18581):        ... 8 more
    E/AndroidRuntime(18581): Caused by: android.database.sqlite.SQLiteDatabaseLockedException: database is locked (code 5 SQLITE_BUSY[5]): , while compiling: PRAGMA journal_mode
    E/AndroidRuntime(18581):        at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
    E/AndroidRuntime(18581):        at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:1463)
    E/AndroidRuntime(18581):        at android.database.sqlite.SQLiteConnection.executeForString(SQLiteConnection.java:1050)
    E/AndroidRuntime(18581):        at android.database.sqlite.SQLiteConnection.setJournalMode(SQLiteConnection.java:606)
    E/AndroidRuntime(18581):        at android.database.sqlite.SQLiteConnection.setWalModeFromConfiguration(SQLiteConnection.java:542)
    E/AndroidRuntime(18581):        at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:378)
    E/AndroidRuntime(18581):        at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:226)
    E/AndroidRuntime(18581):        at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:737)
    E/AndroidRuntime(18581):        at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:284)
    E/AndroidRuntime(18581):        at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:251)
    E/AndroidRuntime(18581):        at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:1392)
    E/AndroidRuntime(18581):        at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:1337)
    E/AndroidRuntime(18581):        at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:980)
    E/AndroidRuntime(18581):        at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:444)
    E/AndroidRuntime(18581):        at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:387)
    E/AndroidRuntime(18581):        at com.google.firebase.firestore.q0.e1.k(Unknown Source:16)
    E/AndroidRuntime(18581):        ... 14 more

【问题讨论】:

    标签: java android firebase flutter google-cloud-firestore


    【解决方案1】:

    打开 Android Studio -> 文件 -> 设置 -> 外观和行为 -> 系统设置 -> Android SDK 。 选择 SDK Tools 并查找 Android SDK 命令行工具(最新)。 选择它并安装更新(如果有)。 点击下方的应用按钮进行安装。

    打开 cmd 并运行“颤振医生”。

    【讨论】:

    • 您将如何在 VSC 中执行此操作?谢谢
    • 首先你必须下载android SDK的cmd工具这个链接:link 下载文件后在页面底部标题(SDK工具包) - 从中​​提取所有文件。 - 打开它并创建一个新文件并将其名称更改为工具并复制工具文件中的其他文件。 - 找到一个带有名称(bin)的文件并打开它 - 单击路径栏并写入 cmd 写入注释:sdkmanager "platform-tools" "platforms;android-30" "build-tools;30.0.2" 按下 Enter 后是@jennie788
    猜你喜欢
    • 1970-01-01
    • 2021-04-23
    • 2020-07-22
    • 2019-10-02
    • 2022-07-04
    • 2020-04-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多