Run Background service Error #86
Description
Which platform(s) does your issue occur on?
- Android version
- emulator and device
Please, provide the following version numbers that your issue occurs with:
- CLI: 3.2.1
- Cross-platform modules: 3.2.0
- Runtime(s): "tns-android": {
"version": "3.2.0"
} - Plugin(s):
"dependencies": {
"buffer": "^5.0.8",
"js-base64": "^2.3.2",
"moment": "^2.19.1",
"native-socket": "file:./files/Nativesocket",
"nativescript-android-utils": "^1.0.2",
"nativescript-bootreceiver": "^1.0.0",
"nativescript-checkbox": "^3.0.1",
"nativescript-couchbase": "^1.0.18",
"nativescript-geolocation": "4.2.0",
"nativescript-loading-indicator": "^2.4.0",
"nativescript-localize": "^2.0.1",
"nativescript-mapbox": "^3.1.2",
"nativescript-permissions": "^1.2.3",
"nativescript-pulltorefresh": "^2.0.2",
"nativescript-secure-storage": "^2.2.1",
"nativescript-theme-core": "~1.0.2",
"nativescript-toast": "^1.4.6",
"netchecksum": "^0.1.1",
"timrjs": "^1.0.1",
"tns-core-modules": "^3.2.0",
"tns-ios": "3.2.0",
"validator": "^8.2.0"
},
"devDependencies": {
"awesome-typescript-loader": "~3.1.3",
"babel-traverse": "6.25.0",
"babel-types": "6.25.0",
"babylon": "6.17.4",
"copy-webpack-plugin": "~4.0.1",
"extract-text-webpack-plugin": "^3.0.1",
"lazy": "1.0.11",
"nativescript-css-loader": "~0.26.0",
"nativescript-dev-sass": "^1.3.2",
"nativescript-dev-typescript": "^0.5.1",
"nativescript-dev-webpack": "^0.8.0",
"nativescript-worker-loader": "~0.8.1",
"raw-loader": "~0.5.1",
"resolve-url-loader": "^2.1.1",
"tns-platform-declarations": "^3.1.1",
"typescript": "^2.5.3",
"webpack": "~3.2.0",
"webpack-bundle-analyzer": "^2.8.2",
"webpack-sources": "~1.0.1"
},
Please, tell us how to recreate the issue in as much detail as possible.
I have a service background and call watch or get position, with version 3.0.1 of the plugin well ok, but whit minors errors, I'am test with versions 4.1.0 and 4.2.0 and
It works very well, so when app is open everything work ok, but when app is close and de service run on background mode i have a error, I'm using
android.app.Service.extend("com.tns.nativescript", {
onStartCommand: function(intent, flags, startId) {
this.super.onStartCommand(intent, flags, startId);
return android.app.Service.START_STICKY;
},
onCreate: function() {
watchLocation(); // here call wathc or get position
},
onBind: function(intent) {
console.log("on Bind Services");
},
onUnbind: function(intent){
console.log('UnBind Service');
},
onDestroy: function(){
console.log('service onDestroy);
}
});
Error:
Error: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.pm.PackageManager android.content.Context.getPackageManager()' on a null object reference
com.google.android.gms.common.zzo.isGooglePlayServicesAvailable(Unknown Source)
com.google.android.gms.common.zze.isGooglePlayServicesAvailable(Unknown Source)
com.google.android.gms.common.GoogleApiAvailability.isGooglePlayServicesAvailable(Unknown Source)
com.tns.Runtime.callJSMethodNative(Native Method)
com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1084)
com.tns.Runtime.callJSMethodImpl(Runtime.java:966)
com.tns.Runtime.callJSMethod(Runtime.java:953)
com.tns.Runtime.callJSMethod(Runtime.java:937)
com.tns.Runtime.callJSMethod(Runtime.java:929)
com.tns.gen.java.lang.Runnable.run(Runnable.java:10)
android.os.Handler.handleCallback(Handler.java:739)
android.os.Handler.dispatchMessage(Handler.java:95)
android.os.Looper.loop(Looper.java:148)
android.app.ActivityThread.main(ActivityThread.java:5417)
java.lang.reflect.Method.invoke(Native Method)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)