美文网首页
引入FlutterBoost遇到的问题

引入FlutterBoost遇到的问题

作者: RookieRun | 来源:发表于2020-07-23 11:02 被阅读0次

1.Exception

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.rookie.hencoder_plus/com.example.rookie.hencoder_plus.flutter_demo.MyFlutterBoostActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'int com.idlefish.flutterboost.Platform.whenEngineStart()' on a null object reference
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3308)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3457)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2044)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:224)
        at android.app.ActivityThread.main(ActivityThread.java:7553)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int com.idlefish.flutterboost.Platform.whenEngineStart()' on a null object reference
        at com.idlefish.flutterboost.containers.FlutterActivityAndFragmentDelegate.onAttach(FlutterActivityAndFragmentDelegate.java:83)
        at com.idlefish.flutterboost.containers.BoostFlutterActivity.onCreate(BoostFlutterActivity.java:143)
        at com.example.rookie.hencoder_plus.flutter_demo.MyFlutterBoostActivity.onCreate(MyFlutterBoostActivity.kt:8)
        at android.app.Activity.performCreate(Activity.java:7893)
        at android.app.Activity.performCreate(Activity.java:7880)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3283)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3457) 
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83) 
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) 
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2044) 
        at android.os.Handler.dispatchMessage(Handler.java:107) 
        at android.os.Looper.loop(Looper.java:224) 
        at android.app.ActivityThread.main(ActivityThread.java:7553) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950) 
2020-07-23 10:50:43.341 566-566/? E/SELinux: avc:  denied  { find } for service=miui.mqsas.MQSService pid=31030 uid=10578 scontext=u:r:untrusted_app_27:s0:c66,c258,c512,c768 tcontext=u:object_r:mqs_service:s0 tclass=service_manager permissive=0
2020-07-23 10:50:43.342 31030-31030/com.example.rookie.hencoder_plus E/MQSEventManagerDelegate: failed to get MQSService.

原因:platform没有初始化
解决办法,在FlutterBoost初始化的时候,初始化platform

 Platform platform = new FlutterBoost
                .ConfigBuilder(this, router)
                .isDebug(true)
                .whenEngineStart(FlutterBoost.ConfigBuilder.ANY_ACTIVITY_CREATED)
                .renderMode(FlutterView.RenderMode.texture)
                .lifecycleListener(boostLifecycleListener)
                .build();
        FlutterBoost.instance().init(platform);

2.FlutterBoost的路由初始化失败


image.png

解决办法

把参数类型去掉就可以了。。。
FlutterBoost.singleton.registerPageBuilders(<String, PageBuilder>{
      'first': (pageName, params, _) => FirstRouteWidget(),
    });

相关文章

网友评论

      本文标题:引入FlutterBoost遇到的问题

      本文链接:https://www.haomeiwen.com/subject/lemclktx.html