Reading in the Google Play Store Console some of my users are having issues with a background service, but I can't replicate it, I don't know what is causing it. For what I can guess, the error occurs when the service is starting or creating, and the java line where it crashes is not something that I wrote on b4a but something b4a adds when compiling I think.
This are the errors:
1)
2)
3)
JAVA LINE 16
JAVA LINE 68
This is how I start the service under Activity_resume (main activity)
I'm running B4A v7.3, thats why I don't use crashlytics.
The devices that sent this errors are all running Android 8.
The first 2 errors were sent by a Mate 10 lite (HWRNE)
The third one was sent by a moto g(6) play (aljeter)
I ran the app in the simulator with Android 8 but no crashes happened.
If more information is needed please let me know.
I'll appreciate your help or suggestions. Thanks in advance.
This are the errors:
1)
B4X:
java.lang.RuntimeException:
at android.app.ActivityThread.handleReceiver (ActivityThread.java:3705)
at android.app.ActivityThread.-wrap18 (Unknown Source)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1979)
at android.os.Handler.dispatchMessage (Handler.java:108)
at android.os.Looper.loop (Looper.java:166)
at android.app.ActivityThread.main (ActivityThread.java:7425)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:245)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:921)
Caused by: java.lang.IllegalStateException:
at android.app.ContextImpl.startServiceCommon (ContextImpl.java:1701)
at android.app.ContextImpl.startService (ContextImpl.java:1657)
at android.content.ContextWrapper.startService (ContextWrapper.java:644)
at android.content.ContextWrapper.startService (ContextWrapper.java:644)
at MYPACKAGENAME.connectionservice$connectionservice_BR.onReceive (connectionservice.java:16)
at android.app.ActivityThread.handleReceiver (ActivityThread.java:3695)
B4X:
java.lang.RuntimeException:
at android.app.ActivityThread.handleServiceArgs (ActivityThread.java:4070)
at android.app.ActivityThread.-wrap21 (Unknown Source)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2016)
at android.os.Handler.dispatchMessage (Handler.java:108)
at android.os.Looper.loop (Looper.java:166)
at android.app.ActivityThread.main (ActivityThread.java:7425)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:245)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:921)
Caused by: java.lang.IllegalStateException:
at android.app.ContextImpl.startServiceCommon (ContextImpl.java:1701)
at android.app.ContextImpl.startService (ContextImpl.java:1657)
at android.content.ContextWrapper.startService (ContextWrapper.java:644)
at anywheresoftware.b4a.keywords.Common.StartService (Common.java:882)
at anywheresoftware.b4a.objects.ServiceHelper$StarterHelper.onStartCommand (ServiceHelper.java:95)
at MYPACKAGENAME.connectionservice.onStartCommand (connectionservice.java:68)
at android.app.ActivityThread.handleServiceArgs (ActivityThread.java:4042)
B4X:
java.lang.RuntimeException:
at android.app.ActivityThread.handleReceiver (ActivityThread.java:3350)
at android.app.ActivityThread.-wrap17 (Unknown Source)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1718)
at android.os.Handler.dispatchMessage (Handler.java:105)
at android.os.Looper.loop (Looper.java:164)
at android.app.ActivityThread.main (ActivityThread.java:6673)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:240)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:769)
Caused by: java.lang.IllegalStateException:
at android.app.ContextImpl.startServiceCommon (ContextImpl.java:1520)
at android.app.ContextImpl.startService (ContextImpl.java:1476)
at android.content.ContextWrapper.startService (ContextWrapper.java:644)
at android.content.ContextWrapper.startService (ContextWrapper.java:644)
at MYPACKAGENAME.connectionservice$connectionservice_BR.onReceive (connectionservice.java:16)
at android.app.ActivityThread.handleReceiver (ActivityThread.java:3343)
JAVA LINE 16
B4X:
......
@Override
public void onReceive(android.content.Context context, android.content.Intent intent) {
android.content.Intent in = new android.content.Intent(context, connectionservice.class);
if (intent != null)
in.putExtra("b4a_internal_intent", intent);
context.startService(in); 'THIS IS LINE 16
}
}
.......
JAVA LINE 68
B4X:
.........
public int onStartCommand(final android.content.Intent intent, int flags, int startId) {
if (ServiceHelper.StarterHelper.onStartCommand(processBA, new Runnable() { 'THIS IS LINE 68
public void run() {
handleStart(intent);
}}))
;
............
This is how I start the service under Activity_resume (main activity)
B4X:
If IsPaused(connectionService) Then
Try
Log("Connecting")
StartService(connectionService)
Catch
End Try
Else
Try
Dim isConnected As Boolean = CallSub(connectionService,"isConnected")
If Not(isConnected) Then
Try
StartService(connectionService)
Catch
End Try
Else
Log("Is already connected")
End If
Catch
Log(LastException)
End Try
End If
I'm running B4A v7.3, thats why I don't use crashlytics.
The devices that sent this errors are all running Android 8.
The first 2 errors were sent by a Mate 10 lite (HWRNE)
The third one was sent by a moto g(6) play (aljeter)
I ran the app in the simulator with Android 8 but no crashes happened.
If more information is needed please let me know.
I'll appreciate your help or suggestions. Thanks in advance.