Android Question java.lang.Exception: Sub service_create signature does not match expected signature.

wimpie3

Well-Known Member
Licensed User
Longtime User
B4X:
java.lang.RuntimeException: java.lang.Exception: Sub service_create signature does not match expected signature.
Has anyone seen this error before? It pops up on my 7 inch android tablet with one particular B4A app.
 

fbritop

Active Member
Licensed User
Longtime User
I'm using a service, for the push notifications. Everything goes fine, the service is persisten. When I run the application in debug, there is no problem, but when I close the application from the memory, and the device receives a message, I get the error in the log that it cannot create the service. I cannot see more details where is the problem, as the main program is not running, I cannot connect the debbuger to the application, just to the system message, and in the device I have a msgbox saying that the app has stop.

My logs are the following:

B4X:
TRACE:LocationChanged
TRACE:LocationChanged
** Activity (amain) Pause, UserClosed = false **
Program compiled in debug mode, can only run with debugger attached.
** Service (pushservice) Create **
java.lang.RuntimeException: Unable to create service cl.abreme.android.pushservice: java.lang.RuntimeException: java.lang.Exception: Sub service_create signature does not match expected signature.
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:2608)
    at android.app.ActivityThread.access$1700(ActivityThread.java:154)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1372)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:5306)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: java.lang.Exception: Sub service_create signature does not match expected signature.
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:148)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:171)
    at cl.abreme.android.pushservice.onCreate(pushservice.java:46)
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:2598)
    ... 10 more
Caused by: java.lang.Exception: Sub service_create signature does not match expected signature.
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:123)
    ... 13 more

The code has the Starting Intenet included. Heres my service module

B4X:
#Region Module Attributes
    #StartAtBoot: False
#End Region

'Service module
'Version 0.9
Sub Process_Globals

End Sub
Sub Service_Create
    Log("SERVICE PUSH")
End Sub

Sub Service_Start (StartingIntent As Intent)
    Try
        Select StartingIntent.Action
            Case "com.google.android.c2dm.intent.REGISTRATION"
                HandleRegistrationResult(StartingIntent)
            Case "com.google.android.c2dm.intent.RECEIVE"
                MessageArrived(StartingIntent)
        End Select
    Catch
  
    End Try
      
End Sub
Sub MessageArrived (Intent As Intent)
    'Log(Intent.ExtrasToString)
    If Intent.GetExtra("code")="status" Then
        Dim sqlString As String="select isOnline from accesos where hashAcceso='" & Intent.GetExtra("hashAcceso") & "'"
        Dim C1 As Cursor
        C1=x.SQLDB.ExecQuery(sqlString)
      
        If C1.RowCount>0 Then
            C1.Position=0
            Dim WhereFields As Map
            WhereFields.Initialize
            WhereFields.Put("hashAcceso", Intent.GetExtra("hashAcceso"))
            DBUtils.UpdateRecord(x.SQLDB, "accesos", "isOnline", Intent.GetExtra("statusCode"), WhereFields)
        End If
        C1.Close
    End If
  
    If x.mac="adetail" Then
        CallSubDelayed2(aDetail, "msgArrival", Intent)
        CallSubDelayed(aDetail, "updateOnlineStatus")
  
    Else If x.mac="amain" AND Intent.GetExtra("code")="status" Then
        CallSubDelayed2(aMain, "msgArrival", Intent)
    End If
End Sub


Sub RegisterDevice (Unregister As Boolean)
    Dim i As Intent
    If Unregister Then      
        i.Initialize("com.google.android.c2dm.intent.UNREGISTER", "")
    Else
        i.Initialize("com.google.android.c2dm.intent.REGISTER", "")
        i.PutExtra("sender", Main.GoogleProjectNumber)
    End If
    Dim r As Reflector
    Dim i2 As Intent
    i2 = r.CreateObject("android.content.Intent")
    Dim pi As Object
    pi = r.RunStaticMethod("android.app.PendingIntent", "getBroadcast", _
        Array As Object(r.GetContext, 0, i2, 0), _
        Array As String("android.content.Context", "java.lang.int", "android.content.Intent", "java.lang.int"))
    i.PutExtra("app", pi)
    StartService(i)
End Sub

Sub HandleRegistrationResult(Intent As Intent)
    Dim url As String="http://www.llavemovil.com/api/ws/push.id.reg.aspx"
    Dim data As String = ""
    If Intent.HasExtra("error") Then
        'Log("Error: " & Intent.GetExtra("error"))
        'ToastMessageShow("Error: " & Intent.GetExtra("error"), True)
    Else If Intent.HasExtra("unregistered") Then
        Dim j As HttpJob
        x.WriteMap("pushId", "")
        j.Initialize("RegisterTask", Me)
        data="token=" & x.ReadMap("token") & "&movil=" & x.ReadMap("movil") & "&pushId=" & x.ReadMap("pushId")
      
        j.PostString(url, data)
        'ToastMessageShow("http://www.llavemovil.com/api/ws/push.id.reg.aspx?token=" & x.ReadMap("token") & "&movil=" & x.ReadMap("movil") & "&pushId=" & x.ReadMap("pushId"), True)
    Else If Intent.HasExtra("registration_id") Then
        Dim rid As String
        rid = Intent.GetExtra("registration_id")
        Dim j As HttpJob
        'Log(rid)
        data="token=" & x.ReadMap("token") & "&pin=" & x.ReadMap("pin") & "&movil=" & x.ReadMap("movil") & "&pushId=" & x.ReadMap("pushId")
        x.WriteMap("pushId", rid)
        'Log(url & "?" & data)
        j.Initialize("RegisterTask", Me)
        j.PostString(url, data)
    End If
End Sub
Sub JobDone(Job As HttpJob)
    If Job.Success Then
        Select Job.JobName
            Case "RegisterTask"
                'ToastMessageShow("Registration completed successfully.", False)
            Case "UnregisterTask"
                'ToastMessageShow("Unregistration completed successfully.", False)
        End Select
    Else
        'ToastMessageShow("Error sending request.", True)
        Log(Job.ErrorMessage)
    End If
    Job.Release
End Sub

Sub Service_Destroy

End Sub

Any chance that someone has encountered this same error?

Thanks in advance
 
Upvote 0

wonder

Expert
Licensed User
Longtime User
Sub MessageArrived (Intent As Intent)

Could it be that this variable's name is the same as its type? I had this error once.
 
Upvote 0
Top