flutter_boost:
git:
url: ' https://github.com/alibaba/flutter_boost.git '
ref: '4.1.1'
webview_flutter: ^3.0.4
步骤
1.BoostNavigator.instance.push(
"xxPage",
);
2. 原生界面val fragment1 = FlutterBoostFragment.CachedEngineFragmentBuilder().urlParams(map as Map<String, Any>?).url("brandExhibitionHallPage").build()
3.E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.vedeng.android.pre, PID: 30986
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.vedeng.android.pre/com.vedeng.android.ui.brand_center.BrandRoomActivity}: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3318)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3429)
at android.app.ActivityThread.-wrap12(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2009)
at android.os.Handler.dispatchMessage(Handler.java:109)
at android.os.Looper.loop(Looper.java:166)
at android.app.ActivityThread.main(ActivityThread.java:7555)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:469)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:963)
Caused by: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
at android.view.ViewGroup.addViewInner(ViewGroup.java:4973)
at android.view.ViewGroup.addView(ViewGroup.java:4804)
at android.view.ViewGroup.addView(ViewGroup.java:4744)
at android.view.ViewGroup.addView(ViewGroup.java:4717)
at io.flutter.plugin.platform.PlatformViewsController.attachToView(PlatformViewsController.java:747)
at io.flutter.embedding.android.FlutterView.attachToFlutterEngine(FlutterView.java:1215)
at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onCreateView(FlutterActivityAndFragmentDelegate.java:337)
at io.flutter.embedding.android.FlutterFragment.onCreateView(FlutterFragment.java:806)
at com.idlefish.flutterboost.containers.FlutterBoostFragment.onCreateView(FlutterBoostFragment.java:93)
at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2963)
at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:518)
at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:282)
at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2189)
at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:2100)
at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:2002)
at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:3138)
at androidx.fragment.app.FragmentManager.dispatchActivityCreated(FragmentManager.java:3072)
at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:251)
at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:502)
at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:210)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1340)
at android.app.Activity.performStart(Activity.java:7364)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3281)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3429)
at android.app.ActivityThread.-wrap12(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2009)
at android.os.Handler.dispatchMessage(Handler.java:109)
at android.os.Looper.loop(Looper.java:166)
at android.app.ActivityThread.main(ActivityThread.java:7555)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:469)
3条答案
按热度按时间hi3rlvi21#
#1755
voj3qocg2#
@joechan-cq 这个问题解决 你们会更新到版本里吗
djmepvbi3#
@joechan-cq 这个问题解决 你们会更新到版本里吗
之前的改法我并不建议整合到release中,只能算是个粗暴的补丁,所以我也没有提PR。
这个问题的根本原因还是在FlutterBoost对
FlutterEngine的detach和attach
与Activity或Fragment的生命周期
的绑定流程上,但这几乎就是FlutterBoost最底层的核心逻辑了,目前我并未去研究有什么更好的绑定流程。至于这个问题的解决方法要不要更新到版本中,需要FB目前的维护者0xZOne来考虑。我个人并不建议Merge。