Skip to content

Unable to start Service when the application process is killed by the OS #1347

@NikolayBa

Description

@NikolayBa

Environment
Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

  • CLI: 5.1
  • Cross-platform modules: 5.1.1
  • Android Runtime: 5.1.0
  • iOS Runtime (if applicable):
  • Plugin(s): Firebase, Angular, GeoLocation

Describe the bug

When the OS kills an app process while a Foreground Service is running (when battery saving are enabled and the app is in the background), Upon the next automatic restart of the Service in the background, the app crashes since the runtime has not started yet.

To Reproduce

  1. Create an Android Service/Foreground Service Example

  2. Let the phone sleep with battery settings enabled or Kill the process manually via adb

  3. Reopen the app or let the service start itself again by the OS. Get the following exception:
    Fatal Exception: java.lang.RuntimeException: Unable to instantiate service com.nativescript.location.BackgroundService: com.tns.NativeScriptException: Failed to create JavaScript extend wrapper for class 'com/nativescript/location/BackgroundService' at android.app.ActivityThread.handleCreateService(ActivityThread.java:3449) at android.app.ActivityThread.-wrap6(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1721) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6682) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)

Expected behavior
When the app process is killed by the OS, the service should be able to boot up again in the background without any exceptions

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions