[TIMOB-17016] Android: Closing Window and returning to TabGroup crashes app with "Unable to instantiate fragment"
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2014-08-27T20:44:17.000+0000 |
Affected Version/s | Release 3.2.3 |
Fix Version/s | Release 3.4.0 |
Components | Android |
Labels | Android, TabGroup, module_tabgroup, qe-testadded |
Reporter | Bar Bruy |
Assignee | Sunila |
Created | 2014-05-19T12:34:38.000+0000 |
Updated | 2014-10-13T21:27:16.000+0000 |
Description
When a window is closed and returns to a tabgroup, the app crashes.
"Unfortunately, YourApp has stopped."
{color:red}
[ERROR] : TiApplication: Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment ti.modules.titanium.ui.widget.tabgroup.TiUIActionBarTab$TabFragment: make sure class name exists, is public, and has an empty constructor that is public
[ERROR] : TiApplication: Caused by: java.lang.InstantiationException: can't instantiate class ti.modules.titanium.ui.widget.tabgroup.TiUIActionBarTab$TabFragment; no empty constructor
{color}
To simulate the error run the code below
+ Developer options -> Enable "Don't keep activities" (Or open plenty of apps in the background)
var tabWin1 = Ti.UI.createWindow({title : 'TW1'});
var tabWin2 = Ti.UI.createWindow({title : 'TW2'});
var tab1 = Ti.UI.createTab({window : tabWin1,title : 'Tab 1'});
var tab2 = Ti.UI.createTab({window : tabWin2,title : 'Tab 2'});
var tabGroup = Ti.UI.createTabGroup({tabs : [tab1,tab2]});
var win2 = Ti.UI.createWindow({title: 'Window 2'});
var openWindowButton = Ti.UI.createButton({widht:Ti.UI.SIZE,height:Ti.UI.SIZE,title:'Open window2'});
tabWin1.add(openWindowButton);
var closeWindowButton = Ti.UI.createButton({widht:Ti.UI.SIZE,height:Ti.UI.SIZE,title:'Close window2'});
win2.add(closeWindowButton);
openWindowButton.addEventListener('click',function(e){win2.open();});
closeWindowButton.addEventListener('click',function(e){win2.close();});
tabGroup.open();
__FULL_ERROR___
{color:red}
[WARN] : dalvikvm: threadid=1: thread exiting with uncaught exception (group=0xa4d48b20)
[ERROR] : TiApplication: (main) [7830,7830] Sending event: exception on thread: main msg:java.lang.RuntimeException: Unable to start activity ComponentInfo{test.geny.com/org.appcelerator.titanium.TiActivity}: android.app.Fragment$InstantiationException: Unable to instantiate fragment ti.modules.titanium.ui.widget.tabgroup.TiUIActionBarTab$TabFragment: make sure class name exists, is public, and has an empty constructor that is public; Titanium 3.2.3,2014/04/22 10:17,b958a70
[ERROR] : TiApplication: java.lang.RuntimeException: Unable to start activity ComponentInfo{test.geny.com/org.appcelerator.titanium.TiActivity}: android.app.Fragment$InstantiationException: Unable to instantiate fragment ti.modules.titanium.ui.widget.tabgroup.TiUIActionBarTab$TabFragment: make sure class name exists, is public, and has an empty constructor that is public
[ERROR] : TiApplication: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
[ERROR] : TiApplication: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
[ERROR] : TiApplication: at android.app.ActivityThread.access$800(ActivityThread.java:135)
[ERROR] : TiApplication: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
[ERROR] : TiApplication: at android.os.Handler.dispatchMessage(Handler.java:102)
[ERROR] : TiApplication: at android.os.Looper.loop(Looper.java:136)
[ERROR] : TiApplication: at android.app.ActivityThread.main(ActivityThread.java:5017)
[ERROR] : TiApplication: at java.lang.reflect.Method.invokeNative(Native Method)
[ERROR] : TiApplication: at java.lang.reflect.Method.invoke(Method.java:515)
[ERROR] : TiApplication: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
[ERROR] : TiApplication: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
[ERROR] : TiApplication: at dalvik.system.NativeStart.main(Native Method)
[ERROR] : TiApplication: Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment ti.modules.titanium.ui.widget.tabgroup.TiUIActionBarTab$TabFragment: make sure class name exists, is public, and has an empty constructor that is public
[ERROR] : TiApplication: at android.app.Fragment.instantiate(Fragment.java:601)
[ERROR] : TiApplication: at android.app.FragmentState.instantiate(Fragment.java:98)
[ERROR] : TiApplication: at android.app.FragmentManagerImpl.restoreAllState(FragmentManager.java:1759)
[ERROR] : TiApplication: at android.app.Activity.onCreate(Activity.java:899)
[ERROR] : TiApplication: at android.support.v4.app.FragmentActivity.onCreate(FragmentActivity.java:204)
[ERROR] : TiApplication: at org.appcelerator.titanium.TiBaseActivity.onCreate(TiBaseActivity.java:520)
[ERROR] : TiApplication: at org.appcelerator.titanium.TiActivity.onCreate(TiActivity.java:18)
[ERROR] : TiApplication: at android.app.Activity.performCreate(Activity.java:5231)
[ERROR] : TiApplication: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
[ERROR] : TiApplication: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
[ERROR] : TiApplication: ... 11 more
[ERROR] : TiApplication: Caused by: java.lang.InstantiationException: can't instantiate class ti.modules.titanium.ui.widget.tabgroup.TiUIActionBarTab$TabFragment; no empty constructor
[ERROR] : TiApplication: at java.lang.Class.newInstanceImpl(Native Method)
[ERROR] : TiApplication: at java.lang.Class.newInstance(Class.java:1208)
[ERROR] : TiApplication: at android.app.Fragment.instantiate(Fragment.java:590)
[ERROR] : TiApplication: ... 20 more
[INFO] : Process: Sending signal. PID: 1446 SIG: 9
{color}
On re-create android requires you to add a empty constructor. I assume this is correctly implemented in Ti.UI.Window but not in Ti.UI.TabGroup ti.modules.titanium.ui.widget.tabgroup.TiUIActionBarTab$TabFragment: make sure class name exists, is public, and has an empty constructor that is public; Titanium sdk 3.2.3.GA tested on Genymotion and LG G TAB 8.3
Moving this ticket to engineering as I can reproduce this issue with the provided test case. Note that this ticket is similar to TIMOB-12939 but that ticket was already fixed in 3.2.0 and I can still reproduce this issue with 3.2.3 release.
I can reproduce this too on an HTC One V , android 4.0.3, Ti 3.2.3.GA Also my client has this on a Samsung S4 Mini (GT-I9195) with android 4.2.2 I don't have the "Don't keep activities" options enabled, however from time to time my app shows the above error when coming back from the background. It's a heavy app and eats pretty much memory so I assume at some point the OS tries to free it. Thank you.
Seeing this on Samsung Galaxy Nexus 4.3 Ti. 3.2.3.GA
Added empty constructor so that Android can restore the state. Since Android restore fragments on orientation change, make sure the properties are set correctly https://github.com/appcelerator/titanium_mobile/pull/5836
The current fix has a few remaining issues and touches a few core areas that make it too risky to pull in at this late stage. Our current plan is to merge this in right post-release, and then affected users can grab it from CI.
@Ingo has the fix been merged to CI?
I'd like to know too :)
It appears we are waiting on another PR to be merged first. [~hpham] can you check please?
Any news? I have an app in production that is crashing every single time it is relaunched.
Extended test case:
Issue Still persist. I tried using the same scenario for the default KS(kitchen sink). Installed the app and then browse other app while my app was in background. After browsing other apps i resumed my app and it crashed. This is happening for any app.(even a single window app) EDIT: SDK version used : 3.4.0.v20140827165712
[~ankesh27] What is the stack trace you get?
its the same Fragment error as mentioned in the issue initially. This time I am using a module but I think the error is not because of the module {color:red} 08-28 19:53:49.025: E/AndroidRuntime(21522): FATAL EXCEPTION: main 08-28 19:53:49.025: E/AndroidRuntime(21522): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myapp/org.appcelerator.titanium.TiActivity}: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment com.navid.tabs.ViewPagerFragment: make sure class name exists, is public, and has an empty constructor that is public 08-28 19:53:49.025: E/AndroidRuntime(21522): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2306) 08-28 19:53:49.025: E/AndroidRuntime(21522): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2358) 08-28 19:53:49.025: E/AndroidRuntime(21522): at android.app.ActivityThread.access$600(ActivityThread.java:156) 08-28 19:53:49.025: E/AndroidRuntime(21522): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1340) 08-28 19:53:49.025: E/AndroidRuntime(21522): at android.os.Handler.dispatchMessage(Handler.java:99) 08-28 19:53:49.025: E/AndroidRuntime(21522): at android.os.Looper.loop(Looper.java:153) 08-28 19:53:49.025: E/AndroidRuntime(21522): at android.app.ActivityThread.main(ActivityThread.java:5297) 08-28 19:53:49.025: E/AndroidRuntime(21522): at java.lang.reflect.Method.invokeNative(Native Method) 08-28 19:53:49.025: E/AndroidRuntime(21522): at java.lang.reflect.Method.invoke(Method.java:511) 08-28 19:53:49.025: E/AndroidRuntime(21522): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833) 08-28 19:53:49.025: E/AndroidRuntime(21522): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) 08-28 19:53:49.025: E/AndroidRuntime(21522): at dalvik.system.NativeStart.main(Native Method) 08-28 19:53:49.025: E/AndroidRuntime(21522): Caused by: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment com.navid.tabs.ViewPagerFragment: make sure class name exists, is public, and has an empty constructor that is public 08-28 19:53:49.025: E/AndroidRuntime(21522): at android.support.v4.app.Fragment.instantiate(Fragment.java:413) 08-28 19:53:49.025: E/AndroidRuntime(21522): at android.support.v4.app.FragmentState.instantiate(Fragment.java:97) 08-28 19:53:49.025: E/AndroidRuntime(21522): at android.support.v4.app.FragmentManagerImpl.restoreAllState(FragmentManager.java:1801) 08-28 19:53:49.025: E/AndroidRuntime(21522): at android.support.v4.app.FragmentActivity.onCreate(FragmentActivity.java:213) 08-28 19:53:49.025: E/AndroidRuntime(21522): at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:97) 08-28 19:53:49.025: E/AndroidRuntime(21522): at org.appcelerator.titanium.TiBaseActivity.onCreate(TiBaseActivity.java:472) 08-28 19:53:49.025: E/AndroidRuntime(21522): at org.appcelerator.titanium.TiActivity.onCreate(TiActivity.java:18) 08-28 19:53:49.025: E/AndroidRuntime(21522): at android.app.Activity.performCreate(Activity.java:5122) 08-28 19:53:49.025: E/AndroidRuntime(21522): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1081) 08-28 19:53:49.025: E/AndroidRuntime(21522): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2270) 08-28 19:53:49.025: E/AndroidRuntime(21522): ... 11 more 08-28 19:53:49.025: E/AndroidRuntime(21522): Caused by: java.lang.InstantiationException: can't instantiate class com.navid.tabs.ViewPagerFragment; no empty constructor 08-28 19:53:49.025: E/AndroidRuntime(21522): at java.lang.Class.newInstanceImpl(Native Method) 08-28 19:53:49.025: E/AndroidRuntime(21522): at java.lang.Class.newInstance(Class.java:1319) 08-28 19:53:49.025: E/AndroidRuntime(21522): at android.support.v4.app.Fragment.instantiate(Fragment.java:402) 08-28 19:53:49.025: E/AndroidRuntime(21522): ... 20 more 08-28 19:53:49.116: E/AppErrorDialog(520): Failed to get ILowStorageHandle instance 08-28 19:53:49.942: E/AEE/DUMPSTATE(21552): copy_process: execv /system/xbin/showmap failed(2), No such file or directory 08-28 19:53:50.451: E/AEE/DUMPSTATE(21550): copy_file: Copy /proc/gpulog to SYS_GPU_INFO failed(2), No such file or directory 08-28 19:53:50.725: E/Fence(610): dequeueBuffer_DEPRECATED: fence 71 didn't signal in 300 ms 08-28 19:53:51.931: E/AEE/DUMPSTATE(21557): copy_process: execv /system/xbin/procrank failed(2), No such file or directory 08-28 19:53:52.770: E/AEE/DUMPSTATE(21550): copy_file: Copy /proc/slabinfo to SYS_SLAB_INFO failed(2), No such file or directory 08-28 19:53:53.116: E/AEE/DUMPSTATE(21550): copy_file: Copy /sys/kernel/debug/wakeup_sources to SYS_KERNEL_WAKELOCKS failed(2), No such file or directory 08-28 19:53:53.206: E/AEE/DUMPSTATE(21562): copy_process: execv /system/xbin/librank failed(2), No such file or directory 08-28 19:53:53.432: E/AEE/DUMPSTATE(21566): copy_process: execv /system/xbin/proc_mem failed(2), No such file or directory {color}
Verified the fix. I built the app with & without a module & did not see any crash or fragment errors. Environment: Appc Studio : 3.4.0.201408270900 Ti SDK : 3.4.0.v20140827165712 Mac OSX : 10.9.4 Alloy : 1.5.0-dev CLI - 3.4.0-dev Code Processor: 1.1.1 Android 4.2 -Nexus 4
Here is the error, I have used KS this time. Again i did the same thing. I opened KS and then pressed home button. I then started browsing other apps for 3 minutes. After returning back to my KS(kitchen-sink) app, it crashed. Below is the ddms log. {color:red} 08-29 10:39:02.519: E/TiApplication(30628): (main) [380,1521] Sending event: exception on thread: main msg:java.lang.RuntimeException: Unable to destroy activity {com.appcelerator.kitchensink/org.appcelerator.titanium.TiActivity}: java.lang.NullPointerException; Titanium 3.4.0,2014/08/27 16:57,5640a23 08-29 10:39:02.519: E/TiApplication(30628): java.lang.RuntimeException: Unable to destroy activity {com.appcelerator.kitchensink/org.appcelerator.titanium.TiActivity}: java.lang.NullPointerException 08-29 10:39:02.519: E/TiApplication(30628): at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3624) 08-29 10:39:02.519: E/TiApplication(30628): at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3642) 08-29 10:39:02.519: E/TiApplication(30628): at android.app.ActivityThread.access$1200(ActivityThread.java:156) 08-29 10:39:02.519: E/TiApplication(30628): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1393) 08-29 10:39:02.519: E/TiApplication(30628): at android.os.Handler.dispatchMessage(Handler.java:99) 08-29 10:39:02.519: E/TiApplication(30628): at android.os.Looper.loop(Looper.java:153) 08-29 10:39:02.519: E/TiApplication(30628): at android.app.ActivityThread.main(ActivityThread.java:5297) 08-29 10:39:02.519: E/TiApplication(30628): at java.lang.reflect.Method.invokeNative(Native Method) 08-29 10:39:02.519: E/TiApplication(30628): at java.lang.reflect.Method.invoke(Method.java:511) 08-29 10:39:02.519: E/TiApplication(30628): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833) 08-29 10:39:02.519: E/TiApplication(30628): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) 08-29 10:39:02.519: E/TiApplication(30628): at dalvik.system.NativeStart.main(Native Method) 08-29 10:39:02.519: E/TiApplication(30628): Caused by: java.lang.NullPointerException 08-29 10:39:02.519: E/TiApplication(30628): at ti.modules.titanium.ui.widget.tabgroup.TiUIActionBarTab$TabFragment.onCreateView(TiUIActionBarTab.java:39) 08-29 10:39:02.519: E/TiApplication(30628): at android.support.v4.app.Fragment.performCreateView(Fragment.java:1500) 08-29 10:39:02.519: E/TiApplication(30628): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:938) 08-29 10:39:02.519: E/TiApplication(30628): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1115) 08-29 10:39:02.519: E/TiApplication(30628): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1097) 08-29 10:39:02.519: E/TiApplication(30628): at android.support.v4.app.FragmentManagerImpl.dispatchReallyStop(FragmentManager.java:1922) 08-29 10:39:02.519: E/TiApplication(30628): at android.support.v4.app.FragmentActivity.onReallyStop(FragmentActivity.java:809) 08-29 10:39:02.519: E/TiApplication(30628): at android.support.v4.app.FragmentActivity.doReallyStop(FragmentActivity.java:786) 08-29 10:39:02.519: E/TiApplication(30628): at android.support.v4.app.FragmentActivity.onDestroy(FragmentActivity.java:333) 08-29 10:39:02.519: E/TiApplication(30628): at org.appcelerator.titanium.TiBaseActivity.onDestroy(TiBaseActivity.java:1245) 08-29 10:39:02.519: E/TiApplication(30628): at org.appcelerator.titanium.TiActivity.onDestroy(TiActivity.java:29) 08-29 10:39:02.519: E/TiApplication(30628): at android.app.Activity.performDestroy(Activity.java:5291) 08-29 10:39:02.519: E/TiApplication(30628): at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1112) 08-29 10:39:02.519: E/TiApplication(30628): at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3611) 08-29 10:39:02.519: E/TiApplication(30628): ... 11 more {color} {color:blue} Operating System Name = Mac OS X Version = 10.9.4 Architecture = 64bit Memory = 8.0GB Node.js Node.js Version = 0.10.31 npm Version = 1.4.23 Titanium CLI CLI Version = 3.3.0 node-appc Version = 0.2.14 Titanium SDKs 3.4.0.v20140827165712 {color}
[~ankesh27] I have also fixed this in my PR for swipe tabs: https://github.com/mokesmokes/titanium_mobile/tree/TIMOB-13392 There are differences since the underlying fragment handling in swipe tabs is totally different, so please give it a shot.
[~mokesmokes] Thank you for sharing, but I am not very sure of how do I use your link. Can you please help me on this. Also, kitchen sink is a default tabbed application, why does it crashes :(
[~ankesh27]
Just make sure to setup your environment as written here: http://docs.appcelerator.com/titanium/3.0/#!/guide/Building_the_Titanium_SDK_From_Source
[~mokesmokes], do you have the compiled version uploaded anywhere, I am struggling to run scons build_jsca=0 Error : {color:red} [exec] /Users/myuser/Documents/android-ndk-r9/build/core/add-application.mk:49: /Users/myuser/Library/Application: No such file or directory [exec] /Users/myuser/Documents/android-ndk-r9/build/core/add-application.mk:186: *** Android NDK: Aborting... . Stop. [exec] Android NDK: There is no Android.mk under /Users/myuser/Library/Application/jni [exec] Android NDK: If this is intentional please define APP_BUILD_SCRIPT to point [exec] Android NDK: to a valid NDK build script. {color}
:( things are same as it were.. I think its a bug in SDK because even the Kitchen -Sink app crashed... It's getting really frustrating for me as I cannot do anything to fix this and I cannot go public with the crash issue. {color:red} 08-29 18:30:21.750: E/AndroidRuntime(22121): FATAL EXCEPTION: main 08-29 18:30:21.750: E/AndroidRuntime(22121): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myapp/org.appcelerator.titanium.TiActivity}: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment com.navid.tabs.ViewPagerFragment: make sure class name exists, is public, and has an empty constructor that is public 08-29 18:30:21.750: E/AndroidRuntime(22121): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2306) 08-29 18:30:21.750: E/AndroidRuntime(22121): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2358) 08-29 18:30:21.750: E/AndroidRuntime(22121): at android.app.ActivityThread.access$600(ActivityThread.java:156) 08-29 18:30:21.750: E/AndroidRuntime(22121): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1340) 08-29 18:30:21.750: E/AndroidRuntime(22121): at android.os.Handler.dispatchMessage(Handler.java:99) 08-29 18:30:21.750: E/AndroidRuntime(22121): at android.os.Looper.loop(Looper.java:153) 08-29 18:30:21.750: E/AndroidRuntime(22121): at android.app.ActivityThread.main(ActivityThread.java:5297) 08-29 18:30:21.750: E/AndroidRuntime(22121): at java.lang.reflect.Method.invokeNative(Native Method) 08-29 18:30:21.750: E/AndroidRuntime(22121): at java.lang.reflect.Method.invoke(Method.java:511) 08-29 18:30:21.750: E/AndroidRuntime(22121): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833) 08-29 18:30:21.750: E/AndroidRuntime(22121): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) 08-29 18:30:21.750: E/AndroidRuntime(22121): at dalvik.system.NativeStart.main(Native Method) 08-29 18:30:21.750: E/AndroidRuntime(22121): Caused by: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment com.navid.tabs.ViewPagerFragment: make sure class name exists, is public, and has an empty constructor that is public 08-29 18:30:21.750: E/AndroidRuntime(22121): at android.support.v4.app.Fragment.instantiate(Fragment.java:413) 08-29 18:30:21.750: E/AndroidRuntime(22121): at android.support.v4.app.FragmentState.instantiate(Fragment.java:97) 08-29 18:30:21.750: E/AndroidRuntime(22121): at android.support.v4.app.FragmentManagerImpl.restoreAllState(FragmentManager.java:1801) 08-29 18:30:21.750: E/AndroidRuntime(22121): at android.support.v4.app.FragmentActivity.onCreate(FragmentActivity.java:213) 08-29 18:30:21.750: E/AndroidRuntime(22121): at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:97) 08-29 18:30:21.750: E/AndroidRuntime(22121): at org.appcelerator.titanium.TiBaseActivity.onCreate(TiBaseActivity.java:472) 08-29 18:30:21.750: E/AndroidRuntime(22121): at org.appcelerator.titanium.TiActivity.onCreate(TiActivity.java:18) 08-29 18:30:21.750: E/AndroidRuntime(22121): at android.app.Activity.performCreate(Activity.java:5122) 08-29 18:30:21.750: E/AndroidRuntime(22121): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1081) 08-29 18:30:21.750: E/AndroidRuntime(22121): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2270) 08-29 18:30:21.750: E/AndroidRuntime(22121): ... 11 more 08-29 18:30:21.750: E/AndroidRuntime(22121): Caused by: java.lang.InstantiationException: can't instantiate class com.navid.tabs.ViewPagerFragment; no empty constructor 08-29 18:30:21.750: E/AndroidRuntime(22121): at java.lang.Class.newInstanceImpl(Native Method) 08-29 18:30:21.750: E/AndroidRuntime(22121): at java.lang.Class.newInstance(Class.java:1319) 08-29 18:30:21.750: E/AndroidRuntime(22121): at android.support.v4.app.Fragment.instantiate(Fragment.java:402) 08-29 18:30:21.750: E/AndroidRuntime(22121): ... 20 more 08-29 18:30:21.810: E/AppErrorDialog(520): Failed to get ILowStorageHandle instance 08-29 18:30:23.468: E/AEE/DUMPSTATE(22149): copy_process: execv /system/xbin/showmap failed(2), No such file or directory 08-29 18:30:23.489: E/Fence(610): dequeueBuffer_DEPRECATED: fence 66 didn't signal in 300 ms 08-29 18:30:24.015: E/AEE/DUMPSTATE(22147): copy_file: Copy /proc/gpulog to SYS_GPU_INFO failed(2), No such file or directory 08-29 18:30:25.597: E/AEE/DUMPSTATE(22156): copy_process: execv /system/xbin/procrank failed(2), No such file or directory 08-29 18:30:26.519: E/AEE/DUMPSTATE(22147): copy_file: Copy /proc/slabinfo to SYS_SLAB_INFO failed(2), No such file or directory 08-29 18:30:26.728: E/AEE/DUMPSTATE(22147): copy_file: Copy /sys/kernel/debug/wakeup_sources to SYS_KERNEL_WAKELOCKS failed(2), No such file or directory 08-29 18:30:26.850: E/AEE/DUMPSTATE(22207): copy_process: execv /system/xbin/librank failed(2), No such file or directory 08-29 18:30:27.177: E/AEE/DUMPSTATE(22212): copy_process: execv /system/xbin/proc_mem failed(2), No such file or directory 08-29 18:30:28.245: E/InputDispatcher(520): channel '4153fd70 com.imdb.mobile/com.imdb.mobile.activity.FragmentMoviesActivity (server)' ~ Channel is unrecoverably broken and will be disposed! 08-29 18:30:28.248: E/InputDispatcher(520): channel '4155bc70 com.imdb.mobile/com.imdb.mobile.activity.movies.MoviesBoxOfficeUSActivity (server)' ~ Channel is unrecoverably broken and will be disposed! {color}
Having almost the same issue. After launching Hello World app, switching between apps and then back to Titanium app, it crashes with this very error. This is using Titanium SDK version 3.3.0.GA (I didn't change one line after doing titanium create --name MyFirstProject) {color:red} (main) [29685,29685] Sending event: exception on thread: main msg:java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test/org.appcelerator.titanium.TiActivity}: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment ti.modules.titanium.ui.widget.tabgroup.TiUIActionBarTab$TabFragment: make sure class name exists, is public, and has an empty constructor that is public; Titanium 3.3.0,2014/07/11 12:36,787cd39 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test/org.appcelerator.titanium.TiActivity}: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment ti.modules.titanium.ui.widget.tabgroup.TiUIActionBarTab$TabFragment: make sure class name exists, is public, and has an empty constructor that is public at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2077) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2102) at android.app.ActivityThread.access$600(ActivityThread.java:137) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4838) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:875) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:642) at dalvik.system.NativeStart.main(Native Method) Caused by: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment ti.modules.titanium.ui.widget.tabgroup.TiUIActionBarTab$TabFragment: make sure class name exists, is public, and has an empty constructor that is public at android.support.v4.app.Fragment.instantiate(Fragment.java:413) at android.support.v4.app.FragmentState.instantiate(Fragment.java:97) at android.support.v4.app.FragmentManagerImpl.restoreAllState(FragmentManager.java:1801) at android.support.v4.app.FragmentActivity.onCreate(FragmentActivity.java:213) at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:97) at org.appcelerator.titanium.TiBaseActivity.onCreate(TiBaseActivity.java:511) at org.appcelerator.titanium.TiActivity.onCreate(TiActivity.java:18) at android.app.Activity.performCreate(Activity.java:5010) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2041) ... 11 more Caused by: java.lang.InstantiationException: can't instantiate class ti.modules.titanium.ui.widget.tabgroup.TiUIActionBarTab$TabFragment; no empty constructor at java.lang.Class.newInstanceImpl(Native Method) at java.lang.Class.newInstance(Class.java:1319) at android.support.v4.app.Fragment.instantiate(Fragment.java:402) ... 20 more {color}
[~ankesh27] the trace you posted is definitely a bug in your module code. Here is the key: {color:red} 08-29 18:30:21.750: E/AndroidRuntime(22121): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myapp/org.appcelerator.titanium.TiActivity}: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment com.navid.tabs.ViewPagerFragment: make sure class name exists, is public, and has an empty constructor that is public {color} Follow the instructions it tells you: make sure class name exists, is public, and has an empty constructor that is public. If Kitchen Sink crashes as well, then please post that stack trace. Did you try to recreate the Kitchen Sink crash with my SDK? Make sure the tabs are swipeable, that's how you will know you're using the right SDK... And don't forget to clean the project build between SDK changes.
swipeable tabs ? [https://gist.github.com/aaronksaunders/2765676] For my swipeable tabs I have used [https://github.com/ricardoalcocer/viewpager]
[~JB] this issue had the fix being discussed here applied after Ti SDK 3.3.0GA SDK was released. You need to install a [continuous build](http://docs.appcelerator.com/titanium/latest/#!/guide/Installing_Titanium_SDK_Continuous_Builds) in order to test the changes. It appears that others are using continuous build version 3.4.0.v20140827165712 as a point of reference.
[~adampax] that worked, thanks!
Tested with an app that was getting the 'unable to instantiate fragment' error on SDKs 3.2.3 and 3.3.0. Ti SDK 3.4.0.v20140827165712 Studio 3.3.0.201407100905 TI CLI 3.3.0 Mac OS X 10.9.4 Galaxy Nexus 4.3 Ran the app, put it in background, opened 4-5 other apps, tried to reopen the app and got this error: {color: red} 08-29 09:54:02.914: E/TiApplication(24550): (main) [694,2934] Sending event: exception on thread: main msg:java.lang.RuntimeException: Unable to destroy activity {com.polancomedia.soonerbeta/org.appcelerator.titanium.TiActivity}: java.lang.NullPointerException; Titanium 3.4.0,2014/08/27 16:57,5640a23 08-29 09:54:02.914: E/TiApplication(24550): java.lang.RuntimeException: Unable to destroy activity {com.polancomedia.soonerbeta/org.appcelerator.titanium.TiActivity}: java.lang.NullPointerException 08-29 09:54:02.914: E/TiApplication(24550): at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3499) 08-29 09:54:02.914: E/TiApplication(24550): at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3517) 08-29 09:54:02.914: E/TiApplication(24550): at android.app.ActivityThread.access$1200(ActivityThread.java:141) 08-29 09:54:02.914: E/TiApplication(24550): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1309) 08-29 09:54:02.914: E/TiApplication(24550): at android.os.Handler.dispatchMessage(Handler.java:99) 08-29 09:54:02.914: E/TiApplication(24550): at android.os.Looper.loop(Looper.java:137) 08-29 09:54:02.914: E/TiApplication(24550): at android.app.ActivityThread.main(ActivityThread.java:5103) 08-29 09:54:02.914: E/TiApplication(24550): at java.lang.reflect.Method.invokeNative(Native Method) 08-29 09:54:02.914: E/TiApplication(24550): at java.lang.reflect.Method.invoke(Method.java:525) 08-29 09:54:02.914: E/TiApplication(24550): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737) 08-29 09:54:02.914: E/TiApplication(24550): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 08-29 09:54:02.914: E/TiApplication(24550): at dalvik.system.NativeStart.main(Native Method) 08-29 09:54:02.914: E/TiApplication(24550): Caused by: java.lang.NullPointerException 08-29 09:54:02.914: E/TiApplication(24550): at ti.modules.titanium.ui.widget.tabgroup.TiUIActionBarTab$TabFragment.onCreateView(TiUIActionBarTab.java:39) 08-29 09:54:02.914: E/TiApplication(24550): at android.support.v4.app.Fragment.performCreateView(Fragment.java:1500) 08-29 09:54:02.914: E/TiApplication(24550): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:938) 08-29 09:54:02.914: E/TiApplication(24550): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1115) 08-29 09:54:02.914: E/TiApplication(24550): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1097) 08-29 09:54:02.914: E/TiApplication(24550): at android.support.v4.app.FragmentManagerImpl.dispatchReallyStop(FragmentManager.java:1922) 08-29 09:54:02.914: E/TiApplication(24550): at android.support.v4.app.FragmentActivity.onReallyStop(FragmentActivity.java:809) 08-29 09:54:02.914: E/TiApplication(24550): at android.support.v4.app.FragmentActivity.doReallyStop(FragmentActivity.java:786) 08-29 09:54:02.914: E/TiApplication(24550): at android.support.v4.app.FragmentActivity.onDestroy(FragmentActivity.java:333) 08-29 09:54:02.914: E/TiApplication(24550): at org.appcelerator.titanium.TiBaseActivity.onDestroy(TiBaseActivity.java:1245) 08-29 09:54:02.914: E/TiApplication(24550): at org.appcelerator.titanium.TiActivity.onDestroy(TiActivity.java:29) 08-29 09:54:02.914: E/TiApplication(24550): at android.app.Activity.performDestroy(Activity.java:5302) 08-29 09:54:02.914: E/TiApplication(24550): at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1117) 08-29 09:54:02.914: E/TiApplication(24550): at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3486) 08-29 09:54:02.914: E/TiApplication(24550): ... 11 more {color}
[~adampax] do you want to give this SDK a try? http://goo.gl/ZtPIFg (the link I gave previously had a bug I since fixed). [~ankesh27] I actually tried the swipe tabs you mention (Ricardo's), and on my Samsung S4 4.4.2 with SDK 3.4.0 it crashed repeatedly. In any case it's missing the point: We want a TabGroup API that is as similar as possible across different platforms (i.e. Ti.UI.TabGroup), and also compatible with existing TabGroup code: you should be able to drop it in to your existing tabbed project and voila - on Android the tabs swipe with zero code changes (e.g. try building Kitchen Sink with it). Plus, I looked at the internal implementation of that project and it needs some work.....
[~mokesmokes] yes that SDK worked for me. Swiping tabs works as well. Tested the same as before: launch app, send to background, open several other apps, then try to resume original app. The app resumed without error with your SDK.
Awesome, good to hear. Hopefully it will be merged soon, in the meantime you can keep up with it at https://github.com/mokesmokes/titanium_mobile/tree/TIMOB-13392
[~ingo] can this ticket be reopened?
[~adampax] I can, but I need a test case attached to the ticket that reproduces the issue. The current test case was verified as fixed. Can you provide one?
[~ingo] sure, but not until Tuesday. Maybe one of the other people following this ticket can hop on here and paste code for a tabgroup app.
[~mokesmokes] I tested this and my app still dies :( I took the master branch (3.4.0.v20140829181714) that seems to have your fixed merged and this is the log I get:
So basically is not a crash by itself, but it seems like a forced restart. Other apps do the same of course, but the behaviour is different, they start as "empty" then show the content, while my app starts "empty" closes, and then starts over again. The device is a OnePlus with Android 4.4.4 on it.
[~rborn] that is not an issue with the PR, but a general Titanium issue I believe. I don't know if they have a plan to deal with this. I agree with you it is an issue that needs to be dealt with.
[~rborn] Is this issue in a different ticket? I'm assuming this is not a regression, correct (or did it work in a previous SDK)?
[~ingo] I only tested with the master branch version above as any other sdk was triggering the crash (Sending event: exception on thread: main msg:java.lang.RuntimeException: Unable to start activity) As I said, this time is not a real crash - aka no error in the console - but more an annoying restart so maybe is not the same issue?
[~mokesmokes] I see, thank you.
For this issue, please update to the latest PR: https://github.com/mokesmokes/titanium_mobile/tree/TIMOB-13392 Now it's fixed :)
[~ingo] , the issue [~rborn] pointed out deserves attention. Can we get some explanation of why Titanium apps need to restart from scratch when killed, and not restart from a previous existing state?
[~mokesmokes] I tried your build (after ages of "scons-ing" :D) and I still have the ugly restart. Or did I understand wrong what's fixed in TIMOB-13392 ?
[~rborn] this issue and my PR only deal with the TabGroup - which crashed the app on occasion. The issue you're pointing out has nothing to do with tabs, and is not a "crash", but a forced restart. It will occur with regular windows as well as tabs. As I said, in my eyes it's a serious issue that needs to be dealt with, but has nothing to do with this particular ticket.
Oh, understood. Thank you.
Verified the fix. We do not see any app crash with "Unable to instantiate fragment" when closing a window & returning to tabgroup. Closing. Environment: Appc Studio : 3.4.0.201409112242 Ti SDK : 3.4.0.v20140912084114 Mac OSX : 10.9.4 Alloy : 1.5.0-rc CLI - 3.4.0-rc2 Code Processor: 1.1.1 Galaxy S4 - android 4.4.2