Skip to content

NS 9: Android JNI crash when app is closed #10998

@felixkrautschuk

Description

@felixkrautschuk

Issue Description

When creating a new NS 9 app, running it on Android and swiping it out of "Recent apps", there seems to be some JNI crash occuring.

screen2.mov

The same is happening when closing the app by tapping the back button of the Android device.

Reproduction

Sample app:

ns9test.zip

Just run it on Android and close it (with Android back button or by swiping it out of "recent apps".

Relevant log output (if applicable)

System.err: An uncaught Exception occurred on "main" thread.
  System.err: Unable to destroy activity {org.nativescript.ns9test/com.tns.NativeScriptActivity}
  System.err:
  System.err: StackTrace:
  System.err: (file:///data/data/org.nativescript.ns9test/files/app/vendor.mjs:2449:38)
  System.err: 	at _handleListenerEntry(file:///data/data/org.nativescript.ns9test/files/app/vendor.mjs:6380:97)
  System.err: 	at _fireEvent(file:///data/data/org.nativescript.ns9test/files/app/vendor.mjs:6369:22)
  System.err: 	at notify(file:///data/data/org.nativescript.ns9test/files/app/vendor.mjs:6351:24)
  System.err: 	at onDestroy(file:///data/data/org.nativescript.ns9test/files/app/vendor.mjs:27935:83)
  System.err: 	at onDestroy(file:///data/data/org.nativescript.ns9test/files/app/vendor.mjs:25050:29)
  System.err: 	at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:6536)
  System.err: 	at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:6568)
  System.err: 	at android.app.servertransaction.DestroyActivityItem.execute(DestroyActivityItem.java:52)
  System.err: 	at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:63)
  System.err: 	at android.app.servertransaction.TransactionExecutor.executeLifecycleItem(TransactionExecutor.java:169)
  System.err: 	at android.app.servertransaction.TransactionExecutor.executeTransactionItems(TransactionExecutor.java:101)
  System.err: 	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:80)
  System.err: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2961)
  System.err: 	at android.os.Handler.dispatchMessage(Handler.java:132)
  System.err: 	at android.os.Looper.dispatchMessage(Looper.java:333)
  System.err: 	at android.os.Looper.loopOnce(Looper.java:263)
  System.err: 	at android.os.Looper.loop(Looper.java:367)
  System.err: 	at android.app.ActivityThread.main(ActivityThread.java:9282)
  System.err: 	at java.lang.reflect.Method.invoke(Native Method)
  System.err: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:566)
  System.err: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:929)
  System.err: Caused by: com.tns.NativeScriptException: Calling js method onDestroy failed
  System.err: Error: JNI Exception occurred (SIGABRT).
  System.err: =======
  System.err: Check the 'adb logcat' for additional information about the error.
  System.err: =======
  System.err:
  System.err: 	at com.tns.Runtime.callJSMethodNative(Native Method)
  System.err: 	at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1316)
  System.err: 	at com.tns.Runtime.callJSMethodImpl(Runtime.java:1202)
  System.err: 	at com.tns.Runtime.callJSMethod(Runtime.java:1189)
  System.err: 	at com.tns.Runtime.callJSMethod(Runtime.java:1167)
  System.err: 	at com.tns.Runtime.callJSMethod(Runtime.java:1163)
  System.err: 	at com.tns.NativeScriptActivity.onDestroy(NativeScriptActivity.java:43)
  System.err: 	at android.app.Activity.performDestroy(Activity.java:9628)
  System.err: 	at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1576)
  System.err: 	at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:6523)
  System.err: 	... 15 more

Environment

OS: macOS 26.1
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Shell: /bin/zsh
node: 22.19.0
npm: 11.6.2
nativescript: 9.0.1

# android
java: 17.0.11
ndk: Not Found
apis: 29, 33, 34, 35, 36, 36
build_tools: 25.0.2, 27.0.3, 28.0.3, 29.0.2, 30.0.2, 30.0.3, 32.0.0, 33.0.0, 33.0.1, 33.0.2, 34.0.0, 35.0.0, 35.0.1, 36.0.0, 36.1.0
system_images: 
  - android-29 | Google Play Intel x86_64 Atom
  - android-35 | Google Play Intel x86_64 Atom
  - android-35 | Google Play Tablet Intel x86_64 Atom
  - android-36.1 | Google Play Intel x86_64 Atom
  - android-36.1 | Pre-Release 16 KB Page Size Google Play Intel x86_64 Atom

# ios
xcode: 26.1.1/17B100
cocoapods: 1.16.2
python: 2.7.18
python3: 3.13.0
ruby: 2.6.10
platforms: 
  - DriverKit 25.1
  - iOS 26.1
  - macOS 26.1
  - tvOS 26.1
  - visionOS 26.1
  - watchOS 26.1

Dependencies

"dependencies": {
  "@nativescript/core": "^9.0.4"
},
"devDependencies": {
  "@nativescript/android": "^9.0.0",
  "@nativescript/ios": "^9.0.1",
  "@nativescript/webpack": "^5.0.27"
}

Please accept these terms

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug-pending-triageReported bug, pending triage to confirm.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions