NativeScript: Intermittent Android Crashing Events
Issue Description
Using nativescript/core alpha, team members are reporting the following errors on Android 12 and 13 devices. Both are a Samsung Galaxy, A90 and A13. ->
Error: java.lang.NoSuchMethodError: no non-static method “Lcom/telerik/android/primitives/widget/sidedrawer/RadSideDrawer;.setMainContent(Ljava/lang/String;)Ljava/io/File;”
Error: ClassNotFoundException when unmarshalling: androidx.core.widget.NestedScrollView$SavedState
Error: Unable to start activity ComponentInfo{com.$$.$$/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: Calling js method onCreate failed Error: java.lang.NoSuchMethodError: no non-static method "Landroidx/appcompat/app/AppCompatActivity;.setContentView(Ljava/lang/String;)Ljava/io/File;
The onCreate failed occurs on an Android 9 moto g6 phone too.
Curiously, on a Realme GT Neo2, it has yet to crash at all when running on alpha
Reproduction
NoSuchMethodError occurs when freshly install the app, delete the old version if it exists and open the app. Twice when attempting to start the app will crash. On the 3rd time opening it runs fine.
To trigger the other errors, start the app, let everything load and then force close. Repeat these steps until the app crashes. Another time the error occurs is when it is left idle and then restarted. At times it crashes and attempts to restart, but gets stuck on the loading screen.
Relevant log output (if applicable)
Error: java.lang.NoSuchMethodError: no non-static method "Lcom/telerik/android/primitives/widget/sidedrawer/RadSideDrawer;.setMainContent(Ljava/lang/String;)Ljava/io/File;"
Error: ClassNotFoundException when unmarshalling: androidx.core.widget.NestedScrollView$SavedState
Error: Unable to start activity ComponentInfo{com.$$.$$/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: Calling js method onCreate failed
Error: java.lang.NoSuchMethodError: no non-static method "Landroidx/appcompat/app/AppCompatActivity;.setContentView(Ljava/lang/String;)Ljava/io/File;
Environment
No response
Please accept these terms
- I have searched the existing issues as well as StackOverflow and this has not been posted before
- This is a bug report
- I agree to follow this project’s Code of Conduct
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 21 (5 by maintainers)
I can confirm that the app on Android is no longer crashing. It was tested on a range of phones, from old phones run on Android 9 to phones running on Android 13.
@SeanKelly369 Oh I see. Latest version of core 8.5 should get this fixed for you then. If you try it and errors stop, let us know so that we can close this.
Nice findings. This will help improving android runtime more in the future. 8.5 will come with more improvements and I think runtimes will keep getting better.
Good news, the app does not crash when reactivated after being left idle when run on NativeScript/core 8.5.0-alpha-5 .
More good news, when force closing and restarting the app, by running gc(); in suspendEvent, there is no longer any crashing taking place - so far.
Therefore, I think it is safe to assume that not all objects and variables are being assigned for garbage collection automatically. Without gc(), when restarting the app, it appears there is a build up of assigned to a memory location code or data, leading to an eventual crash.
Stacktrace from one of the crashes ->
An uncaught Exception occurred on “main” thread. Unable to resume activity {com.app.place/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: Calling js method onCreateView failed Error: java.lang.NoSuchMethodError: no non-static method “Landroid/view/View;.setFocusable(Ljava/lang/String;)Ljava/io/File;”
StackTrace: java.lang.RuntimeException: Unable to resume activity {com.app.place/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: Calling js method onCreateView failed Error: java.lang.NoSuchMethodError: no non-static method “Landroid/view/View;.setFocusable(Ljava/lang/String;)Ljava/io/File;” at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4001) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4033) at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:51) at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:145) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1977) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6923) 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:870) Caused by: com.tns.NativeScriptException: Calling js method onCreateView failed Error: java.lang.NoSuchMethodError: no non-static method “Landroid/view/View;.setFocusable(Ljava/lang/String;)Ljava/io/File;” at com.tns.Runtime.callJSMethodNative(Native Method) at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1302) at com.tns.Runtime.callJSMethodImpl(Runtime.java:1188) at com.tns.Runtime.callJSMethod(Runtime.java:1175) at com.tns.Runtime.callJSMethod(Runtime.java:1153) at com.tns.Runtime.callJSMethod(Runtime.java:1149) at com.tns.FragmentClass.onCreateView(FragmentClass.java:55) at androidx.fragment.app.Fragment.performCreateView(Fragment.java:3104) at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:524) at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:261) at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1899) at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1817) at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1760) at androidx.fragment.app.FragmentController.execPendingActions(FragmentController.java:495) at androidx.fragment.app.FragmentActivity.onResume(FragmentActivity.java:312) at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1434) at android.app.Activity.performResume(Activity.java:7304) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3993) … 11 more Caused by: java.lang.NoSuchMethodError: no non-static method “Landroid/view/View;.setFocusable(Ljava/lang/String;)Ljava/io/File;” … 29 more
I’m unable to run into a crash myself at any point, but others have. I’ve post stacktraces over as soon as possible. It may not be until Monday.