Android Question cvmap view error

Quasarz

New Member
Hi,
I can't resolve this error which only occurs in release build. Do you have any suggestion? Thank you!

*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
*** mainpage: B4XPage_Created
Can use persistant uri!
*** mainpage: B4XPage_Appear
** Activity (main) Resume **
cvmap_update_centerlatlng (java line: 1602)
java.lang.Exception: Sub fcvmap_centerlatlngchanged was not found.
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:227)
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1114)
at anywheresoftware.b4a.keywords.Common.CallSubNew2(Common.java:1069)
at b4a.example.cvmap._update_centerlatlng(cvmap.java:1602)
at b4a.example.cvmap._setcenterlatlng(cvmap.java:1315)
at b4a.example.cvmap._loadlayout(cvmap.java:956)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:221)
at anywheresoftware.b4a.keywords.Common$12.run(Common.java:1212)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:7000)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)
 

Quasarz

New Member
Thanks Erel but I added the event and the type TLatLng is not recognized by the IDE (Are you missing a library reference?).
I changed the type to TmapLatLng but there is the this build error:
java.lang.Exception: Sub fcvmap_centerlatlngchanged signature does not match expected signature.
What am I doing wrong?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Which library?
maybe this one?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
What am I doing wrong?
as per example the sub signature should look like

B4X:
Private Sub fcvMap_CenterLatLngChanged(aLatLng As TMapLatLng)
    Log("lat/Lng changed : " & aLatLng)
End Sub

Note that you need to add the B4XMap b4xlib to your project
 
Upvote 1

Quasarz

New Member
I'll try to explain myself better.
In my B4Xpages project I have inserted the B4Xmap additional library and placed the cvmap view on the visual designer.
Following Erel's suggestion, I have added the event fcvMap_CenterLatLngChanged through the generate members function:
Private Sub fcvMap_CenterLatLngChanged(aOldlatLng As TLatLng,aNewLatLng As TLatLng)
End Sub

As soon as I launch the release build I get this error:
B4A Version: 12.50
Parsing code. Error
Error parsing program.
Error description: Unknown type: tlatlng
Are you missing a library reference?
Error occurred on line: 564 (B4XMainPage)
Private Sub fcvMap_CenterLatLngChanged(aOldlatLng As TLatLng,aNewLatLng As TLatLng)

It seems that the Tlatlng type does not exist in the B4Xmap library, instead the TMapLatLng type of the library does not work with this event (signature error).
Using the debug mode build, without the previous event, the application works perfectly on my tablet.
Thanks for your help.
 
Upvote 0

Quasarz

New Member
I solved the problem:
events created from the designer are wrong. I copied the events from the B4Xmap library example and now the realease building works!
 
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
I solved the problem:
events created from the designer are wrong. I copied the events from the B4Xmap library example and now the realease building works!
I would put it a bit more clearly:

In the library, in cvMap the CenterLatLngChanged was defined like this:

B4X:
#event:CenterLatLngChanged(aOldLatLng as TLatLng,aNewLatLng as TLatLng)

But then in the library in cvMap the event was raised like this:

B4X:
Public Sub Update_CenterLatLng
    
    If fViewCenterLatLng.IsInitialized Then
        fViewCenterLatLng.Text=$"Lat : ${NumberFormat2(fMap.fCenterLatLng.fLat,1,5,5,False)} | Lng : ${NumberFormat2(fMap.fCenterLatLng.fLng,1,5,5,False)}"$
    End If
    If SubExists(mCallBack,mEventName & "_centerLatLngChanged") Then
        CallSub2(mCallBack,mEventName & "_centerLatLngChanged",fMap.fCenterLatLng)
    End If
    
End Sub

So two arguments in the event definition, but only only one argument passed when the event was called.
This caused a problem when you used the generate members function as two arguments were expected, but only one was passed.

To me it looks the generated error description:
Error description: Unknown type: tlatlng
Wasn't quite accurate.

RBS
 
Upvote 0
Top