Flutter发布的应用崩溃并显示灰色屏幕。

huangapple go评论69阅读模式
英文:

Flutter release app crashing and showing gray screen

问题

我在一些安卓设备上运行我的Flutter应用时遇到崩溃问题。

我已经成功调试了应用的发布版本,以下是唯一的调试输出:

W/FlutterJNI(27448): FlutterJNI.loadLibrary called more than once
W/FlutterJNI(27448): FlutterJNI.prefetchDefaultFontManager called more than once
W/FlutterJNI(27448): FlutterJNI.init called more than once

我不知道从哪里开始寻找问题的原因。

设备显示灰屏并停止工作。

英文:

I am getting a crash on some android devices when running my Flutter app.

I have been able to debug a release version of the app and this is the only debug output:

W/FlutterJNI(27448): FlutterJNI.loadLibrary called more than once
W/FlutterJNI(27448): FlutterJNI.prefetchDefaultFontManager called more than once
W/FlutterJNI(27448): FlutterJNI.init called more than once

I don´t know where should I begin to look for the reason of the issue.

The device is showing a gray screen and stops working.

答案1

得分: 2

在创建 firebaseMessagingBackgroundHandler 时,像这样注释它,加上 @pragma('vm:entry-point')

@pragma('vm:entry-point')
Future<void> firebaseMessagingBackgroundHandler(RemoteMessage message) async {

}

原因在这里解释:

https://github.com/firebase/flutterfire/blob/master/packages/firebase_messaging/firebase_messaging/example/lib/main.dart#L46

英文:

Wherever you create the firebaseMessagingBackgroundHandler, annotate it with @pragma(&#39;vm:entry-point&#39;) like this:

@pragma(&#39;vm:entry-point&#39;)
Future&lt;void&gt; firebaseMessagingBackgroundHandler(RemoteMessage message) async {

}

The reason is explained here:

https://github.com/firebase/flutterfire/blob/master/packages/firebase_messaging/firebase_messaging/example/lib/main.dart#L46

huangapple
  • 本文由 发表于 2023年2月14日 20:05:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/75447601.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定