Titanium JIRA Archive
Appcelerator Community (AC)

[AC-1178] Android: App crashes and doesn't starts up normally after been terminated by the device

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionDuplicate
Resolution Date2014-09-03T18:28:38.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
LabelsTCSupportTriage, android, appcompat, crashes, defect, sdk3.3, triageSupport
ReporterLee phela
AssigneeRadamantis Torres-Lechuga
Created2014-08-05T11:41:47.000+0000
Updated2016-03-08T07:37:33.000+0000

Description

It looks like this behavior appears only in the 3.3.0 version of the titanium SDK. When the app running in the background, auto killed by the device to free up memory for other apps, is brought back to the foreground, the app hang up and freezes for 2-6 seconds(depending on the device specs and performances, the better the device, the shorter the freeze), pops-up an alert dialog box "Unfortunately, APP_NAME has stopped", crashes, and then it only starts up. HOW TO REPRODUCE :- Run the kitchen sink project/any hello world program (appcompat theme) and put the app to the background . Open up a browser and navigates to some huge websites loaded with big images and such, so as to make the system force kill our titanium app. When it has been finally killed, try to bring back the same app to the foreground. EXPECTED BEHAVIOR - The app should starts up again normally and there should not be a freeze/alert dialog box popping up/crash. Here is the crash report [code] java.lang.RuntimeException: Unable to start activity ComponentInfo{com.app.id/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:2184) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233) at android.app.ActivityThread.access$800(ActivityThread.java:135) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5001) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) 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:473) at org.appcelerator.titanium.TiActivity.onCreate(TiActivity.java:18) at android.app.Activity.performCreate(Activity.java:5231) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148) ... 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:1208) at android.support.v4.app.Fragment.instantiate(Fragment.java:402) ... 20 more [/code]

Comments

  1. Shuo Liang 2014-08-06

    can't reproduce.
  2. Lee phela 2014-08-11

    Hello Shuo Liang, I dont know why you are closing the issues as irreproducible. In case if you missed anything, here is the exact steps that you need to follow to reproduce it - 1. Create a classic (not alloy) default titanium mobile app project (Tabbed app) or if you have trouble with it, here's the app.js file that you can straightway copy-paste
       
       // this sets the background color of the master UIView (when there are no windows/tab groups on it)
       Titanium.UI.setBackgroundColor('#000');
       
       // create tab group
       var tabGroup = Titanium.UI.createTabGroup();
       
       
       //
       // create base UI tab and root window
       //
       var win1 = Titanium.UI.createWindow({  
           title:'Tab 1',
           backgroundColor:'#fff'
       });
       var tab1 = Titanium.UI.createTab({  
           icon:'KS_nav_views.png',
           title:'Tab 1',
           window:win1
       });
       
       var label1 = Titanium.UI.createLabel({
       	color:'#999',
       	text:'I am Window 1',
       	font:{fontSize:20,fontFamily:'Helvetica Neue'},
       	textAlign:'center',
       	width:'auto'
       });
       
       win1.add(label1);
       
       //
       // create controls tab and root window
       //
       var win2 = Titanium.UI.createWindow({  
           title:'Tab 2',
           backgroundColor:'#fff'
       });
       var tab2 = Titanium.UI.createTab({  
           icon:'KS_nav_ui.png',
           title:'Tab 2',
           window:win2
       });
       
       var label2 = Titanium.UI.createLabel({
       	color:'#999',
       	text:'I am Window 2',
       	font:{fontSize:20,fontFamily:'Helvetica Neue'},
       	textAlign:'center',
       	width:'auto'
       });
       
       win2.add(label2);
       
       
       
       //
       //  add tabs
       //
       tabGroup.addTab(tab1);  
       tabGroup.addTab(tab2);  
       
       
       // open tab group
       tabGroup.open();
       
       
    2. Modify the android tag in your manifest files to something like this
          <android xmlns:android="http://schemas.android.com/apk/res/android">
               <abi>armeabi-v7a,x86</abi>
               <manifest android:versionCode="16" android:versionName="2.0.5">
                   <uses-sdk android:minSdkVersion="15" android:targetSdkVersion="19"/>
                   <application android:debuggable="false"
                       android:hardwareAccelerated="true"
                       android:largeHeap="true" android:theme="@style/Theme.AppCompat.Light">
                   </application>
               </manifest>
           </android>
       
       
    3. Now install the created app to a real device and run it. 4. Put the titanium app to background. 5. Opens up and run as many applications from the phone or go to a really big website and starts browsing and try to force kill our titanium app . 6. When the titanium app is finally killed by the device, try to bring back the titanium app from the background. THE APP FREEZES with just nothing but an empty TABGROUP and hangs forever!
  3. Shawn Lan 2014-08-12

    Hey I encountered the same crash report, after submitting my app to Play Store with SDK 3.3.0. Here is my report. Basically the same: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.app.id/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:2121) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2146) at android.app.ActivityThread.access$700(ActivityThread.java:140) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1238) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4947) 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:1038) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805) 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:473) at org.appcelerator.titanium.TiActivity.onCreate(TiActivity.java:18) at android.app.Activity.performCreate(Activity.java:5207) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2085) ... 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
  4. Shuo Liang 2014-08-12

    [~mpmiranda], Any idea about this situation? we can't reproduce, but customers keeps saying the problem existing.
  5. Lee phela 2014-08-12

    Our is kind of popular in the playstore and we are receiving more than 70-90 crashes and ANR report per day. And we have to continuously keep reminding the users to not background the app during the session of usage , which overall create a horrible bad user experience! The crash is producible only in a real device and not on emulator as it seems like emulator never terminates a backgrounded app due to memory exhaustion! Confirmed and tested on nexus 5 and samsung phones!
  6. Shawn Lan 2014-08-12

    I didn't get such crash report before SDK 3.3.0. That's the thing. What do you mean "not to background the app during the session of usage?" Is that something I can control as an developer? Thanks!
  7. Lee phela 2014-08-12

    I don't think you can control over that! If your app is in the background, the device can kills it anytime when it starts to run low on memory. If the App is normally exited via back button, no such crash is produced! But however if the app is auto killed first by the device, then the app will first splash a white screen, crash it, prompts up an alert dialog box about the crash, and will only starts up again! I'm not sure which causes the crAsh - sdk 3.3.0 or studio 3.3.0 or cli 3.3.0 but one thing that I'm so sure of it is - THIS CRASH STARTS TO APPEARS ONLY AFTER I UPGRADE TO ALL THESE THREE!
  8. Ingo Muschenetz 2014-08-12

    I've placed this into triage.
  9. Ingo Muschenetz 2014-08-25

    [~hpham] to mark as a duplicate of a related issue.

JSON Source