I have a quite vanilla service that works seamlessly when the app is executed on my LG device. Yet when I do it on the Eclipse emulator for the Nexus 5 I get a crash, leaving me with the suspect this behavior could also emerge on real devices different from mine. This is the code:
Intent startBackgroundLocationIntent= new Intent(this, BackgroundLocationService.class);
startService(startBackgroundLocationIntent);
and the crash log:
08-13 14:18:10.731: E/AndroidRuntime(6345): FATAL EXCEPTION: main 08-13 14:18:10.731: E/AndroidRuntime(6345): Process: com.example.taxiprofessional, PID: 6345 08-13 14:18:10.731: E/AndroidRuntime(6345): java.lang.RuntimeException: Unable to start service com.example.taxiprofessional.BackgroundLocationService@b20e39b0 with Intent { cmp=com.example.taxiprofessional/.BackgroundLocationService }: java.lang.NullPointerException 08-13 14:18:10.731: E/AndroidRuntime(6345): at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2719) 08-13 14:18:10.731: E/AndroidRuntime(6345): at android.app.ActivityThread.access$2100(ActivityThread.java:135) 08-13 14:18:10.731: E/AndroidRuntime(6345): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1293) 08-13 14:18:10.731: E/AndroidRuntime(6345): at android.os.Handler.dispatchMessage(Handler.java:102) 08-13 14:18:10.731: E/AndroidRuntime(6345): at android.os.Looper.loop(Looper.java:136) 08-13 14:18:10.731: E/AndroidRuntime(6345): at android.app.ActivityThread.main(ActivityThread.java:5017) 08-13 14:18:10.731: E/AndroidRuntime(6345): at java.lang.reflect.Method.invokeNative(Native Method) 08-13 14:18:10.731: E/AndroidRuntime(6345): at java.lang.reflect.Method.invoke(Method.java:515) 08-13 14:18:10.731: E/AndroidRuntime(6345): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779) 08-13 14:18:10.731: E/AndroidRuntime(6345): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 08-13 14:18:10.731: E/AndroidRuntime(6345): at dalvik.system.NativeStart.main(Native Method) 08-13 14:18:10.731: E/AndroidRuntime(6345): Caused by: java.lang.NullPointerException 08-13 14:18:10.731: E/AndroidRuntime(6345): at com.example.taxiprofessional.BackgroundLocationService.uploadCoordinatesForLocation(BackgroundLocationService.java:100) 08-13 14:18:10.731: E/AndroidRuntime(6345): at com.example.taxiprofessional.BackgroundLocationService.onStartCommand(BackgroundLocationService.java:138) 08-13 14:18:10.731: E/AndroidRuntime(6345): at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2702) 08-13 14:18:10.731: E/AndroidRuntime(6345): ... 10 more