Titanium JIRA Archive
Appcelerator Community (AC)

[AC-5683] Android: Getting crash report from google

GitHub Issuen/a
TypeBug
Priorityn/a
StatusResolved
ResolutionNeeds more info
Resolution Date2018-04-17T21:19:49.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsStudio, Titanium SDK & CLI
Labelsn/a
Reportersonufana4u
AssigneeShak Hossain
Created2018-03-29T12:07:57.000+0000
Updated2020-03-16T12:49:45.000+0000

Description

*Getting crash report from google but don't know how to prevent that.Found below link where its causing the issue at line 258.So how to handle in my application?* https://github.com/appcelerator/titanium_mobile/blob/master/android/titanium/src/java/org/appcelerator/titanium/TiBaseActivity.java {quote} java.lang.RuntimeException: at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2981) at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:3042) at android.app.ActivityThread.-wrap14 (ActivityThread.java) at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1639) at android.os.Handler.dispatchMessage (Handler.java:102) at android.os.Looper.loop (Looper.java:154) at android.app.ActivityThread.main (ActivityThread.java:6776) at java.lang.reflect.Method.invoke (Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1520) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1410) Caused by: java.lang.ClassCastException: at org.appcelerator.titanium.TiBaseActivity.getTiApp (TiBaseActivity.java:248) at org.appcelerator.titanium.TiRootActivity.onCreate (TiRootActivity.java:78) at android.app.Activity.performCreate (Activity.java:6955) at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1126) at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2924) {quote}

Comments

  1. Hans Knöchel 2018-03-29

    I am wondering if this also happens with currnet versions of the SDK, like 7.1.0.GA. [~ybanev] did you see this before?
  2. Yordan Banev 2018-03-29

    Doesn't ring any bell. [~sonufana4u] Any details you can share - code snippet you are suspecting, device, Android version ?
  3. sonufana4u 2018-03-30

    Right now i don't have any info with me but i'll try to share as much as info i could collect.
  4. Mostafizur Rahman 2018-04-01

    [~sonufana4u], Did you manage to collect more information?
  5. sonufana4u 2018-04-02

    Hello Mostafizur, Not yet. Due to long weekend am not able to collect info.Will share with you soon.Thanks
  6. Mostafizur Rahman 2018-04-02

    [~sonufana4u],Ok. Thanks. We will be waiting for that.
  7. Mostafizur Rahman 2018-04-12

    Hello [~sonufana4u], Did you manage to collect more information? We are waiting for that. Thanks
  8. sonufana4u 2018-04-13

    Hi Mostafizur, I didn't get much info but this is happening on Android 7 & Samsung Galaxy S7 edge and Galaxy S8.Check at your end and let me know if it helps to identify the issue.
  9. Sharif AbuDarda 2018-04-13

    Hello, Please share a sample reproducible code for us to test. Thanks.
  10. Sergey Volkov 2018-06-06

    Got same issue. Looks like it is not Titanium specific, but Android 7+. ([stackoverflow](https://stackoverflow.com/questions/44840768/android-7-0-and-7-1-getapplication-classcastexception/46676931)) I think this should fix it:
        --- a/android/titanium/src/java/org/appcelerator/titanium/TiBaseActivity.java
        +++ b/android/titanium/src/java/org/appcelerator/titanium/TiBaseActivity.java
        @@ -263,7 +263,7 @@ public abstract class TiBaseActivity extends AppCompatActivity
                 */
                public TiApplication getTiApp()
                {
        -               return (TiApplication) getApplication();
        +               return TiApplication.getInstance();
                }
        
  11. John Dalsgaard 2018-10-05

    I saw similar issues in my app using SDK 6.3.1. I have now patched the SDK to use this code:
        		TiApplication ta = (TiApplication) getApplication();
        		if(null == ta) {
        		    Log.e("Error", "TiApplication null. Try to load instance...");
        			ta = TiApplication.getInstance();
        		}
        		return ta;
        
    I cannot find a very to directly reproduce this - but I should know within a month or two whether it has removed this type of crashes by looking at the Google Play console. By the way I also checked the code in the lates SDK 7.4.1 - and it still uses:
        	return (TiApplication) getApplication();
        
  12. Sergey Volkov 2018-10-05

    Please use "preview" button (blue button with 3 stripes below comment block). You've just produced over 10 emails. Strip spaces before/after braces: { code:java }CODE HERE{ code }
  13. Sergey Volkov 2018-11-07

    So, this does not help:
        -               return (TiApplication) getApplication();
        +               return TiApplication.getInstance();
        
    Now I got NullPointerExceptions, because somehow there is no TiApplication instance at the moment when TiRootActivity.onCreate executed. As before reports are coming only from Android 7.0 (and some 7.1) and I still have no idea how to reproduce it localy.
  14. grebulon 2019-05-22

    This is not resolved. Got the same crash on Huawei Mate 10 Pro with Android 9: {noformat} java.lang.RuntimeException: at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3300) at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:3484) at android.app.servertransaction.LaunchActivityItem.execute (LaunchActivityItem.java:86) at android.app.servertransaction.TransactionExecutor.executeCallbacks (TransactionExecutor.java:108) at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:68) at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2123) at android.os.Handler.dispatchMessage (Handler.java:109) at android.os.Looper.loop (Looper.java:207) at android.app.ActivityThread.main (ActivityThread.java:7470) at java.lang.reflect.Method.invoke (Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:524) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:958) Caused by: java.lang.ClassCastException: at org.appcelerator.titanium.TiBaseActivity.getTiApp (TiBaseActivity.java:308) at org.appcelerator.titanium.TiRootActivity.onCreate (TiRootActivity.java:80) at android.app.Activity.performCreate (Activity.java:7436) at android.app.Activity.performCreate (Activity.java:7426) at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1286) at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3279) {noformat}
  15. martin 2020-03-16

    Same here, using SDK 8.3.1.GA and seen on LGE LG Q6 (mhn) with Android 8.1 and Samsung Galaxy S8 (dreamlte) with Android 9:
        java.lang.RuntimeException: 
          at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3108)
          at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:3251)
          at android.app.servertransaction.LaunchActivityItem.execute (LaunchActivityItem.java:78)
          at android.app.servertransaction.TransactionExecutor.executeCallbacks (TransactionExecutor.java:108)
          at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:68)
          at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1948)
          at android.os.Handler.dispatchMessage (Handler.java:106)
          at android.os.Looper.loop (Looper.java:214)
          at android.app.ActivityThread.main (ActivityThread.java:7045)
          at java.lang.reflect.Method.invoke (Native Method)
          at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:493)
          at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:964)
        Caused by: java.lang.ClassCastException: 
          at org.appcelerator.titanium.TiBaseActivity.getTiApp (TiBaseActivity.java:225)
          at org.appcelerator.titanium.TiBaseActivity.finish (TiBaseActivity.java:1763)
          at org.appcelerator.titanium.TiActivity.onCreate (TiActivity.java:42)
          at android.app.Activity.performCreate (Activity.java:7327)
          at android.app.Activity.performCreate (Activity.java:7318)
          at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1271)
          at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3088)
        

JSON Source