java.lang.RuntimeException: Unable to start activity ComponentInfo{com.bd.apptest1/org.appcelerator.titanium.TiActivity}: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.

Appcelerator JIRA | Motiur Rahman | 2 years ago
  1. 0

    App crashes if we use the searchBar properties borderRadius, borderColor, or borderWidth. And use this searchBar in a tableView using search property. h3.Testing Environment: Titanium SDK: 3.3.0.GA, 3.2.3.GA Titanium CLI: 3.3.0, Android SDK: 4.2.2, 4.4.2 OS X Version: 10.9.3, Appcelerator Studio: 3.3.0 h3.Steps to Reproduce the issue: 1. Create classic project. 2. Paste this code app.js file. 3. Run this code with the testing environment. h3.Test Code {code:title=app.js} var win = Titanium.UI.createWindow({ title : "search bar" }); // create table view data object var data = []; data[0] = Ti.UI.createTableViewRow({ hasChild : true, title : 'Row 1' }); data[1] = Ti.UI.createTableViewRow({ hasDetail : true, title : 'Row 2' }); data[2] = Ti.UI.createTableViewRow({ hasCheck : true, title : 'Row 3' }); data[3] = Ti.UI.createTableViewRow({ title : 'Row 4' }); var search = Titanium.UI.createSearchBar({ borderRadius : 10, borderColor : 'red', borderWidth : 2, showCancel : true, height : 60, hintText : "Filter results", }); // create table view var tableview = Titanium.UI.createTableView({ data : data, top : 40, search : search, filterAttribute : "title", }); win.add(tableview); win.open(); {code} {code:title=application log} [ERROR] : TiApplication: (main) [107,107] Sending event: exception on thread: main msg:java.lang.RuntimeException: Unable to start activity ComponentInfo{com.bd.apptest1/org.appcelerator.titanium.TiActivity}: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.; Titanium 3.2.3,2014/04/22 10:17,b958a70 [ERROR] : TiApplication: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.bd.apptest1/org.appcelerator.titanium.TiActivity}: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first. [ERROR] : TiApplication: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180) [ERROR] : TiApplication: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230) [ERROR] : TiApplication: at android.app.ActivityThread.access$600(ActivityThread.java:141) [ERROR] : TiApplication: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234) [ERROR] : TiApplication: at android.os.Handler.dispatchMessage(Handler.java:99) [ERROR] : TiApplication: at android.os.Looper.loop(Looper.java:137) [ERROR] : TiApplication: at android.app.ActivityThread.main(ActivityThread.java:5041) [ERROR] : TiApplication: at java.lang.reflect.Method.invokeNative(Native Method) [ERROR] : TiApplication: at java.lang.reflect.Method.invoke(Method.java:511) [ERROR] : TiApplication: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) [ERROR] : TiApplication: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) [ERROR] : TiApplication: at dalvik.system.NativeStart.main(Native Method) [ERROR] : TiApplication: Caused by: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first. [ERROR] : TiApplication: at android.view.ViewGroup.addViewInner(ViewGroup.java:3339) [ERROR] : TiApplication: at android.view.ViewGroup.addView(ViewGroup.java:3210) [ERROR] : TiApplication: at android.view.ViewGroup.addView(ViewGroup.java:3186) [ERROR] : TiApplication: at ti.modules.titanium.ui.widget.TiUITableView.processProperties(TiUITableView.java:155) [ERROR] : TiApplication: at org.appcelerator.kroll.KrollProxy.setModelListener(KrollProxy.java:1185) [ERROR] : TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:480) [ERROR] : TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:471) [ERROR] : TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:449) [ERROR] : TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:487) [ERROR] : TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:471) [ERROR] : TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:449) [ERROR] : TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.handleAdd(TiViewProxy.java:566) [ERROR] : TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.add(TiViewProxy.java:544) [ERROR] : TiApplication: at ti.modules.titanium.ui.WindowProxy.windowCreated(WindowProxy.java:303) [ERROR] : TiApplication: at org.appcelerator.titanium.TiActivityWindows.windowCreated(TiActivityWindows.java:32) [ERROR] : TiApplication: at org.appcelerator.titanium.TiBaseActivity.windowCreated(TiBaseActivity.java:452) [ERROR] : TiApplication: at org.appcelerator.titanium.TiBaseActivity.onCreate(TiBaseActivity.java:528) [ERROR] : TiApplication: at org.appcelerator.titanium.TiActivity.onCreate(TiActivity.java:18) [ERROR] : TiApplication: at android.app.Activity.performCreate(Activity.java:5104) [ERROR] : TiApplication: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080) [ERROR] : TiApplication: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144) [ERROR] : TiApplication: ... 11 more {code} Thanks

    Appcelerator JIRA | 2 years ago | Motiur Rahman
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.bd.apptest1/org.appcelerator.titanium.TiActivity}: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
  2. 0

    App crashes if we use the searchBar properties borderRadius, borderColor, or borderWidth. And use this searchBar in a tableView using search property. h3.Testing Environment: Titanium SDK: 3.3.0.GA, 3.2.3.GA Titanium CLI: 3.3.0, Android SDK: 4.2.2, 4.4.2 OS X Version: 10.9.3, Appcelerator Studio: 3.3.0 h3.Steps to Reproduce the issue: 1. Create classic project. 2. Paste this code app.js file. 3. Run this code with the testing environment. h3.Test Code {code:title=app.js} var win = Titanium.UI.createWindow({ title : "search bar" }); // create table view data object var data = []; data[0] = Ti.UI.createTableViewRow({ hasChild : true, title : 'Row 1' }); data[1] = Ti.UI.createTableViewRow({ hasDetail : true, title : 'Row 2' }); data[2] = Ti.UI.createTableViewRow({ hasCheck : true, title : 'Row 3' }); data[3] = Ti.UI.createTableViewRow({ title : 'Row 4' }); var search = Titanium.UI.createSearchBar({ borderRadius : 10, borderColor : 'red', borderWidth : 2, showCancel : true, height : 60, hintText : "Filter results", }); // create table view var tableview = Titanium.UI.createTableView({ data : data, top : 40, search : search, filterAttribute : "title", }); win.add(tableview); win.open(); {code} {code:title=application log} [ERROR] : TiApplication: (main) [107,107] Sending event: exception on thread: main msg:java.lang.RuntimeException: Unable to start activity ComponentInfo{com.bd.apptest1/org.appcelerator.titanium.TiActivity}: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.; Titanium 3.2.3,2014/04/22 10:17,b958a70 [ERROR] : TiApplication: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.bd.apptest1/org.appcelerator.titanium.TiActivity}: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first. [ERROR] : TiApplication: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180) [ERROR] : TiApplication: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230) [ERROR] : TiApplication: at android.app.ActivityThread.access$600(ActivityThread.java:141) [ERROR] : TiApplication: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234) [ERROR] : TiApplication: at android.os.Handler.dispatchMessage(Handler.java:99) [ERROR] : TiApplication: at android.os.Looper.loop(Looper.java:137) [ERROR] : TiApplication: at android.app.ActivityThread.main(ActivityThread.java:5041) [ERROR] : TiApplication: at java.lang.reflect.Method.invokeNative(Native Method) [ERROR] : TiApplication: at java.lang.reflect.Method.invoke(Method.java:511) [ERROR] : TiApplication: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) [ERROR] : TiApplication: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) [ERROR] : TiApplication: at dalvik.system.NativeStart.main(Native Method) [ERROR] : TiApplication: Caused by: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first. [ERROR] : TiApplication: at android.view.ViewGroup.addViewInner(ViewGroup.java:3339) [ERROR] : TiApplication: at android.view.ViewGroup.addView(ViewGroup.java:3210) [ERROR] : TiApplication: at android.view.ViewGroup.addView(ViewGroup.java:3186) [ERROR] : TiApplication: at ti.modules.titanium.ui.widget.TiUITableView.processProperties(TiUITableView.java:155) [ERROR] : TiApplication: at org.appcelerator.kroll.KrollProxy.setModelListener(KrollProxy.java:1185) [ERROR] : TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:480) [ERROR] : TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:471) [ERROR] : TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:449) [ERROR] : TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:487) [ERROR] : TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:471) [ERROR] : TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:449) [ERROR] : TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.handleAdd(TiViewProxy.java:566) [ERROR] : TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.add(TiViewProxy.java:544) [ERROR] : TiApplication: at ti.modules.titanium.ui.WindowProxy.windowCreated(WindowProxy.java:303) [ERROR] : TiApplication: at org.appcelerator.titanium.TiActivityWindows.windowCreated(TiActivityWindows.java:32) [ERROR] : TiApplication: at org.appcelerator.titanium.TiBaseActivity.windowCreated(TiBaseActivity.java:452) [ERROR] : TiApplication: at org.appcelerator.titanium.TiBaseActivity.onCreate(TiBaseActivity.java:528) [ERROR] : TiApplication: at org.appcelerator.titanium.TiActivity.onCreate(TiActivity.java:18) [ERROR] : TiApplication: at android.app.Activity.performCreate(Activity.java:5104) [ERROR] : TiApplication: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080) [ERROR] : TiApplication: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144) [ERROR] : TiApplication: ... 11 more {code} Thanks

    Appcelerator JIRA | 2 years ago | Motiur Rahman
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.bd.apptest1/org.appcelerator.titanium.TiActivity}: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
  3. 0

    +Test Code+: //FirstView Component Constructor var flag = false; function FirstView(win) { // Create a Button. var showHideButton = Ti.UI.createButton({ title : 'Show / Hide', height : 75, width : '100%', top : 0, left : 0 }); // Listen for click events. showHideButton.addEventListener('click', function() { if(true == flag) { win.add(self); flag = false; } else { win.remove(self); flag = true; } }); // Add to the parent view. win.add(showHideButton); var self = Ti.UI.createView({ top : 100, left : 0 }); win.add(self); var sb = Titanium.UI.createSearchBar({ barColor : '#122a6f', showCancel : false, height : 44, }); // Create a TableView. var aTableView = Ti.UI.createTableView({ height : 600, width : '100%', search : sb, top : 0, left : 0 }); // Populate the TableView data. var data = [ {title:'Row 1', hasChild:true, color:'red', header:'First'}, {title:'Row 2', hasDetail:true, color:'green'}, {title:'Row 3', hasCheck:true, color:'blue', header:'Second'}, {title:'Row 4', color:'orange'} ]; aTableView.setData(data); // Listen for click events. aTableView.addEventListener('click', function(e) { alert('title: \'' + e.row.title + '\', section: \'' + e.section.headerTitle + '\', index: ' + e.index); }); // Add to the parent view. self.add(aTableView); return self; } module.exports = FirstView; +Test Case+: 1. Launch the application 2. Press the hide / show button to hide the table. 3. Press it again to show the table. +Expected behavior+: The table should get displayed again. +Actual Behavior+: The application crashes with the following ADB log: D/AndroidRuntime( 3890): Shutting down VM W/dalvikvm( 3890): threadid=1: thread exiting with uncaught exception (group=0x40c451f8) E/TiApplication( 3890): (main) [6288,6382] Sending event: exception on thread: main msg:java.lang.IllegalStateException: The specified child already has a p t. You must call removeView() on the child's parent first.; Titanium 1.8.2,2012/02/23 17:46,59b3a90 E/TiApplication( 3890): java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first. E/TiApplication( 3890): at android.view.ViewGroup.addViewInner(ViewGroup.java:3337) E/TiApplication( 3890): at android.view.ViewGroup.addView(ViewGroup.java:3208) E/TiApplication( 3890): at android.view.ViewGroup.addView(ViewGroup.java:3188) E/TiApplication( 3890): at ti.modules.titanium.ui.widget.TiUITableView.processProperties(TiUITableView.java:131) E/TiApplication( 3890): at org.appcelerator.kroll.KrollProxy.setModelListener(KrollProxy.java:641) E/TiApplication( 3890): at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:464) E/TiApplication( 3890): at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:456) E/TiApplication( 3890): at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:434) E/TiApplication( 3890): at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:471) E/TiApplication( 3890): at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:456) E/TiApplication( 3890): at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:434) E/TiApplication( 3890): at org.appcelerator.titanium.proxy.TiViewProxy.handleAdd(TiViewProxy.java:538) E/TiApplication( 3890): at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:271) E/TiApplication( 3890): at org.appcelerator.titanium.proxy.TiWindowProxy.handleMessage(TiWindowProxy.java:109) E/TiApplication( 3890): at ti.modules.titanium.ui.ActivityWindowProxy.handleMessage(ActivityWindowProxy.java:94) E/TiApplication( 3890): at android.os.Handler.dispatchMessage(Handler.java:95) E/TiApplication( 3890): at android.os.Looper.loop(Looper.java:137) E/TiApplication( 3890): at android.app.ActivityThread.main(ActivityThread.java:4507) E/TiApplication( 3890): at java.lang.reflect.Method.invokeNative(Native Method) E/TiApplication( 3890): at java.lang.reflect.Method.invoke(Method.java:511) E/TiApplication( 3890): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790) E/TiApplication( 3890): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557) E/TiApplication( 3890): at dalvik.system.NativeStart.main(Native Method) E/AndroidRuntime( 3890): FATAL EXCEPTION: main E/AndroidRuntime( 3890): java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first. E/AndroidRuntime( 3890): at android.view.ViewGroup.addViewInner(ViewGroup.java:3337) E/AndroidRuntime( 3890): at android.view.ViewGroup.addView(ViewGroup.java:3208) E/AndroidRuntime( 3890): at android.view.ViewGroup.addView(ViewGroup.java:3188) E/AndroidRuntime( 3890): at ti.modules.titanium.ui.widget.TiUITableView.processProperties(TiUITableView.java:131) E/AndroidRuntime( 3890): at org.appcelerator.kroll.KrollProxy.setModelListener(KrollProxy.java:641) E/AndroidRuntime( 3890): at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:464) E/AndroidRuntime( 3890): at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:456) E/AndroidRuntime( 3890): at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:434) E/AndroidRuntime( 3890): at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:471) E/AndroidRuntime( 3890): at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:456) E/AndroidRuntime( 3890): at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:434) E/AndroidRuntime( 3890): at org.appcelerator.titanium.proxy.TiViewProxy.handleAdd(TiViewProxy.java:538) E/AndroidRuntime( 3890): at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:271) E/AndroidRuntime( 3890): at org.appcelerator.titanium.proxy.TiWindowProxy.handleMessage(TiWindowProxy.java:109) E/AndroidRuntime( 3890): at ti.modules.titanium.ui.ActivityWindowProxy.handleMessage(ActivityWindowProxy.java:94) E/AndroidRuntime( 3890): at android.os.Handler.dispatchMessage(Handler.java:95) E/AndroidRuntime( 3890): at android.os.Looper.loop(Looper.java:137) E/AndroidRuntime( 3890): at android.app.ActivityThread.main(ActivityThread.java:4507) E/AndroidRuntime( 3890): at java.lang.reflect.Method.invokeNative(Native Method) E/AndroidRuntime( 3890): at java.lang.reflect.Method.invoke(Method.java:511) E/AndroidRuntime( 3890): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790) E/AndroidRuntime( 3890): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557) E/AndroidRuntime( 3890): at dalvik.system.NativeStart.main(Native Method) W/ActivityManager( 1985): Force finishing activity r.intent.getComponent().flattenToShortString() +Others+: The above code works fine if the search bar is removed. +Attachments+: The source code has been attached.

    Appcelerator JIRA | 4 years ago | Soumya Kanti Kar
    java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    h3. Expected Behavior The app launch, pressing the button shows another window with a search bar in a table, then pushing the hardware back button take us to the first window, then push again the button to open the window with the search bar again, needs to work and open the window with the search bar again h3. Actual Behavior When I push the button to open the search bar window for the second time, the application crash and throw this message: {code} msg:java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first {code} h3. Steps to reproduce - Push the button - use hardware button to go back to the first screen - Push the button again - Crash h3. Test Case {code:title=app.js|borderStyle=solid} var page1 = require("page1"); page1.win.open(); {code} {code:title=page1.js|borderStyle=solid} var win = Ti.UI.createWindow({ backgroundColor:"white", navBarHidden:false }); var button = Ti.UI.createButton({ title:"button" }); win.add(button); var page2 = require("page2"); button.addEventListener('click', function(){ page2.win.open(); }) exports.win = win; {code} {code:title=page2.js|borderStyle=solid} var win = Ti.UI.createWindow({ backgroundColor : "white", navBarHidden : false }); var search = Ti.UI.createSearchBar(); var table = Ti.UI.createTableView({ search:search }); win.add(table); exports.win = win; {code} {code:title=Log|borderStyle=solid} I/ActivityManager( 62): Starting: Intent { cmp=com.appcelerator.app283994/org.appcelerator.titanium.TiActivity (has extras) } from pid 412 D/AndroidRuntime( 412): Shutting down VM W/dalvikvm( 412): threadid=1: thread exiting with uncaught exception (group=0x40015560) E/TiApplication( 412): (main) [2630,9831] Sending event: exception on thread: main msg:java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.; Titanium 1.9.0,2012/01/03 08:46,428293e E/TiApplication( 412): java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first. E/TiApplication( 412): at android.view.ViewGroup.addViewInner(ViewGroup.java:1976) E/TiApplication( 412): at android.view.ViewGroup.addView(ViewGroup.java:1871) E/TiApplication( 412): at android.view.ViewGroup.addView(ViewGroup.java:1851) E/TiApplication( 412): at ti.modules.titanium.ui.widget.TiUITableView.processProperties(TiUITableView.java:131) E/TiApplication( 412): at org.appcelerator.kroll.KrollProxy.setModelListener(KrollProxy.java:641) E/TiApplication( 412): at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:449) E/TiApplication( 412): at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:441) E/TiApplication( 412): at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:427) E/TiApplication( 412): at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:456) E/TiApplication( 412): at ti.modules.titanium.ui.ActivityWindowProxy.handleMessage(ActivityWindowProxy.java:81) E/TiApplication( 412): at android.os.Handler.dispatchMessage(Handler.java:95) E/TiApplication( 412): at android.os.Looper.loop(Looper.java:130) E/TiApplication( 412): at android.app.ActivityThread.main(ActivityThread.java:3683) E/TiApplication( 412): at java.lang.reflect.Method.invokeNative(Native Method) E/TiApplication( 412): at java.lang.reflect.Method.invoke(Method.java:507) E/TiApplication( 412): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) E/TiApplication( 412): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) E/TiApplication( 412): at dalvik.system.NativeStart.main(Native Method) I/ActivityManager( 62): Displayed com.appcelerator.app283994/org.appcelerator.titanium.TiActivity: +364ms E/AndroidRuntime( 412): FATAL EXCEPTION: main E/AndroidRuntime( 412): java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first. E/AndroidRuntime( 412): at android.view.ViewGroup.addViewInner(ViewGroup.java:1976) E/AndroidRuntime( 412): at android.view.ViewGroup.addView(ViewGroup.java:1871) E/AndroidRuntime( 412): at android.view.ViewGroup.addView(ViewGroup.java:1851) E/AndroidRuntime( 412): at ti.modules.titanium.ui.widget.TiUITableView.processProperties(TiUITableView.java:131) E/AndroidRuntime( 412): at org.appcelerator.kroll.KrollProxy.setModelListener(KrollProxy.java:641) E/AndroidRuntime( 412): at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:449) E/AndroidRuntime( 412): at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:441) E/AndroidRuntime( 412): at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:427) E/AndroidRuntime( 412): at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:456) E/AndroidRuntime( 412): at ti.modules.titanium.ui.ActivityWindowProxy.handleMessage(ActivityWindowProxy.java:81) E/AndroidRuntime( 412): at android.os.Handler.dispatchMessage(Handler.java:95) E/AndroidRuntime( 412): at android.os.Looper.loop(Looper.java:130) E/AndroidRuntime( 412): at android.app.ActivityThread.main(ActivityThread.java:3683) E/AndroidRuntime( 412): at java.lang.reflect.Method.invokeNative(Native Method) E/AndroidRuntime( 412): at java.lang.reflect.Method.invoke(Method.java:507) E/AndroidRuntime( 412): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) E/AndroidRuntime( 412): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) E/AndroidRuntime( 412): at dalvik.system.NativeStart.main(Native Method) W/ActivityManager( 62): Force finishing activity com.appcelerator.app283994/org.appcelerator.titanium.TiActivity {code}

    Appcelerator JIRA | 5 years ago | Radamantis Torres-Lechuga
    java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
  6. 0

    +Test Code+: //FirstView Component Constructor var flag = false; function FirstView(win) { // Create a Button. var showHideButton = Ti.UI.createButton({ title : 'Show / Hide', height : 75, width : '100%', top : 0, left : 0 }); // Listen for click events. showHideButton.addEventListener('click', function() { if(true == flag) { win.add(self); flag = false; } else { win.remove(self); flag = true; } }); // Add to the parent view. win.add(showHideButton); var self = Ti.UI.createView({ top : 100, left : 0 }); win.add(self); var sb = Titanium.UI.createSearchBar({ barColor : '#122a6f', showCancel : false, height : 44, }); // Create a TableView. var aTableView = Ti.UI.createTableView({ height : 600, width : '100%', search : sb, top : 0, left : 0 }); // Populate the TableView data. var data = [ {title:'Row 1', hasChild:true, color:'red', header:'First'}, {title:'Row 2', hasDetail:true, color:'green'}, {title:'Row 3', hasCheck:true, color:'blue', header:'Second'}, {title:'Row 4', color:'orange'} ]; aTableView.setData(data); // Listen for click events. aTableView.addEventListener('click', function(e) { alert('title: \'' + e.row.title + '\', section: \'' + e.section.headerTitle + '\', index: ' + e.index); }); // Add to the parent view. self.add(aTableView); return self; } module.exports = FirstView; +Test Case+: 1. Launch the application 2. Press the hide / show button to hide the table. 3. Press it again to show the table. +Expected behavior+: The table should get displayed again. +Actual Behavior+: The application crashes with the following ADB log: D/AndroidRuntime( 3890): Shutting down VM W/dalvikvm( 3890): threadid=1: thread exiting with uncaught exception (group=0x40c451f8) E/TiApplication( 3890): (main) [6288,6382] Sending event: exception on thread: main msg:java.lang.IllegalStateException: The specified child already has a p t. You must call removeView() on the child's parent first.; Titanium 1.8.2,2012/02/23 17:46,59b3a90 E/TiApplication( 3890): java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first. E/TiApplication( 3890): at android.view.ViewGroup.addViewInner(ViewGroup.java:3337) E/TiApplication( 3890): at android.view.ViewGroup.addView(ViewGroup.java:3208) E/TiApplication( 3890): at android.view.ViewGroup.addView(ViewGroup.java:3188) E/TiApplication( 3890): at ti.modules.titanium.ui.widget.TiUITableView.processProperties(TiUITableView.java:131) E/TiApplication( 3890): at org.appcelerator.kroll.KrollProxy.setModelListener(KrollProxy.java:641) E/TiApplication( 3890): at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:464) E/TiApplication( 3890): at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:456) E/TiApplication( 3890): at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:434) E/TiApplication( 3890): at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:471) E/TiApplication( 3890): at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:456) E/TiApplication( 3890): at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:434) E/TiApplication( 3890): at org.appcelerator.titanium.proxy.TiViewProxy.handleAdd(TiViewProxy.java:538) E/TiApplication( 3890): at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:271) E/TiApplication( 3890): at org.appcelerator.titanium.proxy.TiWindowProxy.handleMessage(TiWindowProxy.java:109) E/TiApplication( 3890): at ti.modules.titanium.ui.ActivityWindowProxy.handleMessage(ActivityWindowProxy.java:94) E/TiApplication( 3890): at android.os.Handler.dispatchMessage(Handler.java:95) E/TiApplication( 3890): at android.os.Looper.loop(Looper.java:137) E/TiApplication( 3890): at android.app.ActivityThread.main(ActivityThread.java:4507) E/TiApplication( 3890): at java.lang.reflect.Method.invokeNative(Native Method) E/TiApplication( 3890): at java.lang.reflect.Method.invoke(Method.java:511) E/TiApplication( 3890): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790) E/TiApplication( 3890): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557) E/TiApplication( 3890): at dalvik.system.NativeStart.main(Native Method) E/AndroidRuntime( 3890): FATAL EXCEPTION: main E/AndroidRuntime( 3890): java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first. E/AndroidRuntime( 3890): at android.view.ViewGroup.addViewInner(ViewGroup.java:3337) E/AndroidRuntime( 3890): at android.view.ViewGroup.addView(ViewGroup.java:3208) E/AndroidRuntime( 3890): at android.view.ViewGroup.addView(ViewGroup.java:3188) E/AndroidRuntime( 3890): at ti.modules.titanium.ui.widget.TiUITableView.processProperties(TiUITableView.java:131) E/AndroidRuntime( 3890): at org.appcelerator.kroll.KrollProxy.setModelListener(KrollProxy.java:641) E/AndroidRuntime( 3890): at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:464) E/AndroidRuntime( 3890): at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:456) E/AndroidRuntime( 3890): at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:434) E/AndroidRuntime( 3890): at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:471) E/AndroidRuntime( 3890): at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:456) E/AndroidRuntime( 3890): at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:434) E/AndroidRuntime( 3890): at org.appcelerator.titanium.proxy.TiViewProxy.handleAdd(TiViewProxy.java:538) E/AndroidRuntime( 3890): at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:271) E/AndroidRuntime( 3890): at org.appcelerator.titanium.proxy.TiWindowProxy.handleMessage(TiWindowProxy.java:109) E/AndroidRuntime( 3890): at ti.modules.titanium.ui.ActivityWindowProxy.handleMessage(ActivityWindowProxy.java:94) E/AndroidRuntime( 3890): at android.os.Handler.dispatchMessage(Handler.java:95) E/AndroidRuntime( 3890): at android.os.Looper.loop(Looper.java:137) E/AndroidRuntime( 3890): at android.app.ActivityThread.main(ActivityThread.java:4507) E/AndroidRuntime( 3890): at java.lang.reflect.Method.invokeNative(Native Method) E/AndroidRuntime( 3890): at java.lang.reflect.Method.invoke(Method.java:511) E/AndroidRuntime( 3890): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790) E/AndroidRuntime( 3890): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557) E/AndroidRuntime( 3890): at dalvik.system.NativeStart.main(Native Method) W/ActivityManager( 1985): Force finishing activity r.intent.getComponent().flattenToShortString() +Others+: The above code works fine if the search bar is removed. +Attachments+: The source code has been attached.

    Appcelerator JIRA | 4 years ago | Soumya Kanti Kar
    java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. 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()
  2. Android Platform
    ViewGroup.addView
    1. android.view.ViewGroup.addViewInner(ViewGroup.java:3339)
    2. android.view.ViewGroup.addView(ViewGroup.java:3210)
    3. android.view.ViewGroup.addView(ViewGroup.java:3186)
    3 frames
  3. ti.modules.titanium
    TiUITableView.processProperties
    1. ti.modules.titanium.ui.widget.TiUITableView.processProperties(TiUITableView.java:155)
    1 frame
  4. org.appcelerator.kroll
    KrollProxy.setModelListener
    1. org.appcelerator.kroll.KrollProxy.setModelListener(KrollProxy.java:1185)
    1 frame
  5. org.appcelerator.titanium
    TiViewProxy.add
    1. org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:480)
    2. org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:471)
    3. org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:449)
    4. org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:487)
    5. org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:471)
    6. org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:449)
    7. org.appcelerator.titanium.proxy.TiViewProxy.handleAdd(TiViewProxy.java:566)
    8. org.appcelerator.titanium.proxy.TiViewProxy.add(TiViewProxy.java:544)
    8 frames
  6. ti.modules.titanium
    WindowProxy.windowCreated
    1. ti.modules.titanium.ui.WindowProxy.windowCreated(WindowProxy.java:303)
    1 frame
  7. org.appcelerator.titanium
    TiActivity.onCreate
    1. org.appcelerator.titanium.TiActivityWindows.windowCreated(TiActivityWindows.java:32)
    2. org.appcelerator.titanium.TiBaseActivity.windowCreated(TiBaseActivity.java:452)
    3. org.appcelerator.titanium.TiBaseActivity.onCreate(TiBaseActivity.java:528)
    4. org.appcelerator.titanium.TiActivity.onCreate(TiActivity.java:18)
    4 frames
  8. Android Platform
    ActivityThread.main
    1. android.app.Activity.performCreate(Activity.java:5104)
    2. android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
    3. android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
    4. android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
    5. android.app.ActivityThread.access$600(ActivityThread.java:141)
    6. android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
    7. android.os.Handler.dispatchMessage(Handler.java:99)
    8. android.os.Looper.loop(Looper.java:137)
    9. android.app.ActivityThread.main(ActivityThread.java:5041)
    9 frames
  9. Java RT
    Method.invoke
    1. java.lang.reflect.Method.invokeNative(Native Method)
    2. java.lang.reflect.Method.invoke(Method.java:511)
    2 frames
  10. Android
    ZygoteInit.main
    1. com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
    2. com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
    2 frames
  11. Android Platform
    NativeStart.main
    1. dalvik.system.NativeStart.main(Native Method)
    1 frame