I'm trying to make specialized virtual assistant in nativescript on android. For that I need a background service constantly listening for the wake word. Now I managed to make a service, but when it's restarted after app kill with START\_STICKY it crashes with `com.tns.NativeScriptException: Failed to create JavaScript extend wrapper for class 'tk/ozymandias/ServiceTest/Service'`.

Here's the service:

```
@JavaProxy("tk.ozymandias.ServiceTest.Service")
class Service extends android.app.Service {
    private timerId: number;

    onBind():android.os.IBinder {
        return null;
    }

    onCreate(): void {
        super.onCreate();
        if (!this.timerId) {
            this.timerId = setInterval(() => {
                console.log("PING");
            }, 1000);
        }
    }

    onStartCommand(intent: android.content.Intent, flags: number, startId: number) {
        return android.app.Service.START_STICKY;
    }

    onDestroy(): void {
        super.onDestroy();
        clearInterval(this.timerId);
    }
}

```

And here's the stack trace:

```
An uncaught Exception occurred on "main" thread.
Unable to create service tk.ozymandias.ServiceTest.Service: com.tns.NativeScriptException: Failed to create JavaScript extend wrapper for class 'tk/ozymandias/ServiceTest/Service'

StackTrace:
java.lang.RuntimeException: Unable to create service tk.ozymandias.ServiceTest.Service: com.tns.NativeScriptException: Failed to create JavaScript extend wrapper for class 'tk/ozymandias/ServiceTest/Service'
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:3349)
    at android.app.ActivityThread.-wrap4(Unknown Source:0)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1677)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6494)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:440)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
    at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:108)
Caused by: com.tns.NativeScriptException: Failed to create JavaScript extend wrapper for class 'tk/ozymandias/ServiceTest/Service'
    at com.tns.Runtime.createJSInstanceNative(Native Method)
    at com.tns.Runtime.createJSInstance(Runtime.java:778)
    at com.tns.Runtime.initInstance(Runtime.java:751)
    at tk.ozymandias.ServiceTest.Service.onCreate(Service.java:29)
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:3339)
    ... 9 more

```

You can see minimal sample project [here](https://github.com/OzymandiasTheGreat/nativescript-servicetest).
For the error to trigger you need to actually kill the app, exiting with back button works just fine.

Edit: [here's a new repo with working code](https://github.com/OzymandiasTheGreat/Nativescript-ServiceExample)