flutter android 应用程序在发布模式下冻结在启动屏幕上

use*_*247 6 android gradle flutter

我在使用存储来保存用户登录数据时遇到问题。

像这样的场景:登录后,我清除应用程序并尝试再次重新打开它,有时它会打开,有时会在启动屏幕上冻结。这仅发生在发布模式下。

我尝试删除每个包,直到发现登录后使用存储的问题。所以如果我不登录,什么都不会冻结。

我使用了 get_storage 、shared_preferences 和 secure_storage 包,但没有任何改变。颤振2.10.2。

在真实设备上测试

这也是使用过的包

module:
  androidX: true # Add this line.

environment:
  sdk: ">=2.11.0 <3.0.0"

dependencies:
  dio: ^4.0.0
  get: ^4.1.4
  get_storage:
  flutter:
    sdk: flutter


dev_dependencies:
  flutter_launcher_icons: ^0.9.2

flutter_icons:
  android: true
  ios: false
  image_path: "assets/icons/launcher_icon.png"
  flutter_test:
    sdk: flutter

name: delivery
description: manager App
version: 1.6.3
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
Run Code Online (Sandbox Code Playgroud)

最后我决定分享详细的希望有人可以提供帮助

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

Giu*_*nci 6

I had a similar bug:

  • By default on Android, android:allowBackup is set to true which means that your app's data is automatically backed up to your Google Drive
  • The problem is when something in your data structure changes but you have an old backup with an old and incompatible data structure. When reinstalling a new version of the app which is incompatible with the old data structure which was backed up, it will freeze on the native splash screen.

I solved this by adding android:allowBackup="false" to android/app/src/main/AndroidManifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    ...
    <application
        ...
        android:allowBackup="false"
        ...
    </application>
</manifest>

Run Code Online (Sandbox Code Playgroud)


小智 5

几天前我在我们的生产应用程序中遇到了同样的问题。我发布了 Flutter 2.10.2 的更新(仅在本地应用程序数据库中更新了几个表),许多用户开始遇到冻结的启动屏幕。

经过几天的尝试解决这个问题,我终于将 Flutter 降级到 2.8 并发布了更新,问题就消失了。