Android Question Geolocation runs fine in debug mode but crashes in release mode

ciginfo

Well-Known Member
Licensed User
Longtime User
Hello,
My app uses Geolocation and GoogleMapsExtras libraries. It works fine in Debug mode but crashes in Release mode. If I use "#BridgeLogger: True" I get the following error message: "java.lang.Exception: Sub geolocation_location was not found." in the attached code.
Any idea where the problem lies?
Thank you
B4X:
Sub MY_POSITION
    Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION)
    wait for Activity_PermissionResult (Permission As String, Result As Boolean)
    If Result Then
        GeoLoc.Initialize("GeoLocation")
        GeoLoc.GetLocation
        GeoLoc.geoAddress
        EditText1.Text = GeoLoc.Address

        Lati3 = GeoLoc.Lattitude
        longi3 = GeoLoc.Longitude
        'Ajoute le Marker
        gmap = MapFragment1.GetMap
        Marker3 = gmap.AddMarker(Lati3, longi3, "Ma Position")
        
        'Centre la carte et zoome
        Dim cp As CameraPosition
        cp.Initialize(Lati3, longi3, gmap.CameraPosition.Zoom)
        cp.Initialize(Lati3, longi3, 10) 'zoom taille du zoom (de 1 à 15)
        gmap.AnimateCamera(cp)

        'Ajoute un cercle
            Dim co As CircleOptions
            co.Initialize
            co.Center2(Lati3, longi3).Radius(1000).FillColor(Colors.ARGB(25,8,45,80)).StrokeColor(Colors.Black)
            Circle3 = gmapExtra.AddCircle(gmap, co)
    
    Else
        ToastMessageShow("Position non trouvée", True)
    End If
End Sub
 

LucaMs

Expert
Licensed User
Longtime User
I state that I have never used / played with these things (maybe a moment, just out of curiosity, millennia ago)...

"java.lang.Exception: Sub geolocation_location was not found."
It is likely that the library will not check for the existence of an event routine before attempting to run it; this can probably be fixedby writing the empty event routine Sub geolocation_location.

This, however, does not justify the fact that in debug mode the app does not give errors. Maybe it depends on how you launch your routine MY_POSITION and what is written after calling this routine. You probably have to call it using Wait For (you should modify your routine so that it returns a Resumable type and as the last line Return True or False or whatever.

B4X:
Sub MY_POSITION As ResumableSub
   '...
   Return True
End Sub

B4X:
Wait For (MY_POSITION) Complete(Unused As Boolean)
 
Upvote 0

ciginfo

Well-Known Member
Licensed User
Longtime User
Thank you, but it does not run. I don't understand why it runs fine in debug mode and crashes in release mode.
Here the Manifest.
B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="29"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
CreateResourceFromFile(Macro, Themes.LightTheme)
'End of default text.

CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)

AddApplicationText(
<meta-data
  android:name="com.google.android.geo.API_KEY"
  android:value="AIzaSyAj******************loAOIP4rs"/>
)

AddApplicationText(
<uses-library
      android:name="org.apache.http.legacy"
      android:required="false" />
)
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Have you implemented the Geolocation_Location event sub?

 
Upvote 0

ciginfo

Well-Known Member
Licensed User
Longtime User
Yes, yes, yes, that was the error, indeed I forgot to implement the Geolocation_Location
Thanks again Erel. But I still don't understand why it worked in debug mode and not in release mode
Thank you
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Yes, yes, yes, that was the error, indeed I forgot to implement the Geolocation_Location
Thanks again Erel. But I still don't understand why it worked in debug mode and not in release mode

 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…