Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
5.2k views
in Technique[技术] by (71.8m points)

Flutter: Crash in release mode for android V2 upgrade

I upgrade my android to V2 and now my app crash at the splash screen in release mode.

This is the error I see

Caused by java.lang.IllegalStateException: ensureInitializationComplete must be called after startInitialization
       at io.flutter.embedding.engine.loader.FlutterLoader.ensureInitializationComplete(FlutterLoader.java:292)
       at io.flutter.view.FlutterMain.ensureInitializationComplete(FlutterMain.java:8)
       at io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService.onCreate(FlutterFirebaseMessagingService.java:10)
       at android.app.ActivityThread.handleCreateService(ActivityThread.java:3542)
       at android.app.ActivityThread.-wrap4(ActivityThread.java)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1786)
       at android.os.Handler.dispatchMessage(Handler.java:105)
       at android.os.Looper.loop(Looper.java:164)
       at android.app.ActivityThread.main(ActivityThread.java:6938)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)

I am using Flutter 1.22.4

Please let me know how to fix this issue.

Thanks


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

try adding

FlutterMain.startInitialization(this);

before super.onCreate in MainActivity

For Example

class MainActivity : FlutterActivity() {

  override protected fun onCreate(savedInstanceState: Bundle?) {
    FlutterMain.startInitialization(this) // This Line
    super.onCreate(savedInstanceState)
    GeneratedPluginRegistrant.registerWith(this)
  }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...