Android Question GoogleMaps doesn't work

Roger C

Active Member
Licensed User
Longtime User
Hi,

I'm trying out Google Maps and found this tutorial:
https://www.b4x.com/android/forum/threads/google-maps.63930/

It just shows a white screen and no map.
So i searched and found this (among others):
https://www.b4x.com/android/forum/threads/google-map-v2-white-map-on-device.56962/

I tried the runtime permission check too:
https://www.b4x.com/android/forum/t...ty-exemptions-on-android-7.88995/#post-563422

No luck. Still white screen with Google-logo and +/- buttons, but no map...

Problem is that Google API pages doesn't look at all as they used to when i programmed 3-4 years ago and not like the examples in the forum.
Maps API comes in a new version sine July 2018 too and I don't know if that has anything to do with it.... Now it's called Maps SDK for Android.

So I don't know what's wrong; Google API registration, GoogleMaps v2.02, missing files, ....

I have GoogleMaps v2.02, Reflection v2.40 and RunTimePermission v1.10 as libraries. Don't know what to do...

B4X:
#Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
    #AdditionalJar: com.google.android.gms:play-services-maps
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim rp As RuntimePermissions
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    
    Private gmap As GoogleMap
    Private MapFragment1 As MapFragment

End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    Activity.LoadLayout("MapView")
    If MapFragment1.IsGooglePlayServicesAvailable = False Then
        ToastMessageShow("Please install Google Play Services.", True)
    End If
    'Log(IsActivityAvailable("com.google.android.gms"))
    
End Sub


Sub MapFragment1_Ready
    gmap = MapFragment1.GetMap
    rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION)
    Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
    gmap.MyLocationEnabled = Result
    Dim m1 As Marker = gmap.AddMarker(10, 30, "test")
    m1.Snippet = "This is the snippet"
End Sub

Sub Activity_PermissionResult (Permission As String, Result As Boolean)
    If Permission = rp.PERMISSION_ACCESS_FINE_LOCATION Then
        gmap.MyLocationEnabled = Result
    End If
End Sub

And here's the logfile. Full of errors.

B4X:
*** Debugger waiting for connection (1) ***
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Class com.google.android.gms.common.GoogleApiAvailability failed lock verification and will run slower.
Class com.google.android.gms.common.internal.MetadataValueReader failed lock verification and will run slower.
Class com.google.android.gms.common.GoogleSignatureVerifier failed lock verification and will run slower.
Class com.google.android.gms.common.GoogleCertificates failed lock verification and will run slower.
Class com.google.android.gms.common.zzc failed lock verification and will run slower.
true
** Activity (main) Resume **
Skipped 53 frames!  The application may be doing too much work on its main thread.
Relayout returned: old=[0,0][1080,1920] new=[0,0][1080,1920] result=0x1 surface={valid=true 482467811328} changed=false
Making Creator dynamically
Class com.google.android.gms.dynamite.DynamiteModule failed lock verification and will run slower.
Skipping duplicate class check due to unrecognized classloader
Considering local module com.google.android.gms.maps_dynamite:0 and remote module com.google.android.gms.maps_dynamite:220
Selected remote version of com.google.android.gms.maps_dynamite, version >= 220
Skipping duplicate class check due to unrecognized classloader
Google Play services client version: 12451000
Google Play services package version: 12874025
The String#value field is not present on Android versions >= 6.0
** Activity (main) Pause, UserClosed = false **
MSG_WINDOW_FOCUS_CHANGED 0
MSG_WINDOW_FOCUS_CHANGED 1
Skipped 38 frames!  The application may be doing too much work on its main thread.
Relayout returned: old=[0,0][1080,1920] new=[0,0][1080,1920] result=0x1 surface={valid=true 482467811328} changed=false
sf_framedrop debug : 0x4f4c, game : false, logging : 0
sf_framedrop debug : 0x4f4c, game : false, logging : 0
EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, egl_color_buffer_format *, EGLBoolean) returns 0x3000,  [1015x1364]-format:2
** Activity (main) Resume **
Skipped 68 frames!  The application may be doing too much work on its main thread.
Do partial code cache collection, code=28KB, data=24KB
After code cache collection, code=27KB, data=24KB
Increasing code cache capacity to 128KB
Local module descriptor class for com.google.android.gms.googlecertificates not found.
Considering local module com.google.android.gms.googlecertificates:0 and remote module com.google.android.gms.googlecertificates:4
Selected remote version of com.google.android.gms.googlecertificates, version >= 4
Skipping duplicate class check due to unrecognized classloader
Authorization failure.  Please see https://developers.google.com/maps/documentation/android-api/start for how to correctly set up the map.
In the Google Developer Console (https://console.developers.google.com)
Ensure that the "Google Maps Android API v2" is enabled.
Ensure that the following Android Key exists:
    API Key: AIzaSyC21fNplIPntcbMu_JVcVOlwF1HOoJLtHk
    Android Application (<cert_fingerprint>;<package_name>): DD:2B:8F:AB:67:57:7C:E5:57:12:D9:88:1D:EB:A7:E7:6D:7B:8D:F5;b4a.example
Starting input: tba=android.view.inputmethod.EditorInfo@61ac26b nm : b4a.example ic=null
startInputInner - mService.startInputOrWindowGainedFocus
getExtractedText on inactive InputConnection
getTextBeforeCursor on inactive InputConnection
** Activity (main) Pause, UserClosed = false **
performDraw() was skipped by AOD_SHOW_STATE... DisplayState=3
MSG_WINDOW_FOCUS_CHANGED 0
eglDestroySurface = 0x705d21d460
Relayout returned: old=[0,0][1080,1920] new=[0,0][1080,1920] result=0x5 surface={valid=false 0} changed=true
Relayout returned: old=[0,0][1080,1920] new=[0,0][1080,1920] result=0x1 surface={valid=false 0} changed=false
sf_framedrop debug : 0x4f4c, game : false, logging : 0
EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, egl_color_buffer_format *, EGLBoolean) returns 0x3000,  [1015x1364]-format:2
sf_framedrop debug : 0x4f4c, game : false, logging : 0
Relayout returned: old=[0,0][1080,1920] new=[0,0][1080,1920] result=0x7 surface={valid=true 482467811328} changed=true
EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, egl_color_buffer_format *, EGLBoolean) returns 0x3000,  [1080x1920]-format:1
eglCreateWindowSurface = 0x705d21d460
** Activity (main) Resume **
Skipped 51 frames!  The application may be doing too much work on its main thread.
MSG_WINDOW_FOCUS_CHANGED 1
Starting input: tba=android.view.inputmethod.EditorInfo@cf53186 nm : b4a.example ic=null
startInputInner - mService.startInputOrWindowGainedFocus

And here's 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="26"/>
<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.DarkTheme)
'End of default text.

'Google Service
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)

'Google Maps
AddApplicationText(
<meta-data
  android:name="com.google.android.geo.API_KEY"
  android:value="AIzaSyC21fNplIPntcbMu_JVcVOlwF1HOoJLtHk "/>
)
 
Top