Skip to content

The specified child already has a parent (when dynamically creating Frame & Page) #6931

@webleaf

Description

@webleaf

Environment

  • CLI: 5.2.0
  • Cross-platform modules: 5.2.1
  • Android Runtime: 5.2.1

Describe the bug
Related with #6312 #6201 #6339

System.err: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
System.err: 	at android.view.ViewGroup.addViewInner(ViewGroup.java:4658)
System.err: 	at android.view.ViewGroup.addView(ViewGroup.java:4499)
System.err: 	at android.view.ViewGroup.addView(ViewGroup.java:4439)
System.err: 	at android.view.ViewGroup.addView(ViewGroup.java:4412)
System.err: 	at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1466)
System.err: 	at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1784)
System.err: 	at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1852)
System.err: 	at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:802)
System.err: 	at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2625)
System.err: 	at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2411)
System.err: 	at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2366)
System.err: 	at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2273)
System.err: 	at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:733)
System.err: 	at android.os.Handler.handleCallback(Handler.java:751)
System.err: 	at android.os.Handler.dispatchMessage(Handler.java:95)
System.err: 	at android.os.Looper.loop(Looper.java:154)
System.err: 	at android.app.ActivityThread.main(ActivityThread.java:6776)
System.err: 	at java.lang.reflect.Method.invoke(Native Method)
System.err: 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1518)
System.err: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)

To Reproduce
After app is opened press Back button to "close" app. Then run (resume) app again by pressing app icon.

Sample project

import * as app from "tns-core-modules/application";
import {parse} from "tns-core-modules/ui/builder";
import {StackLayout} from "tns-core-modules/ui/layouts/stack-layout";
import {Page} from "tns-core-modules/ui/page";
import {Frame} from "tns-core-modules/ui/frame";

const rootLayoutXml = `<StackLayout><Frame id="rootLayoutFrame"/></StackLayout>`;
const rootLayoutView = <StackLayout>parse(rootLayoutXml);

const pageXml = `<Page><StackLayout><Label text="Text"/></StackLayout></Page>`;
const pageView = <Page>parse(pageXml);

const rootLayoutFrame = <Frame>rootLayoutView.getViewById("rootLayoutFrame");

app.run({
    create: () => {

        rootLayoutFrame.navigate({
            create: () => pageView
        });

        return rootLayoutView;
    }
});

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions