Android Question What is causing my maps to crash?

alexwekell

Member
Licensed User
Longtime User
My code:

B4X:
#Region  Project Attributes
    #ApplicationLabel: MAPS TEST
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
   
#End Region

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

'Activity module
Sub Process_Globals

End Sub

Sub Globals
  Dim mFragment As MapFragment
  Dim gmap As GoogleMap
  Dim MapPanel As Panel
End Sub

Sub Activity_Create(FirstTime As Boolean)
  MapPanel.Initialize("")
  Activity.AddView(MapPanel, 0, 0, 100%x, 100%y)
  If mFragment.IsGooglePlayServicesAvailable = False Then
      ToastMessageShow("Google Play services not available.", True)
  Else
      mFragment.Initialize("Map", MapPanel)
  End If
End Sub
Sub Map_Ready
  Log("map ready")
  gmap = mFragment.GetMap
  If gmap.IsInitialized = False Then
      ToastMessageShow("Error initializing map.", True)
  Else
      gmap.AddMarker(36, 15, "Hello!!!")
      Dim cp As CameraPosition
      cp.Initialize(36, 15, gmap.CameraPosition.Zoom)
      gmap.AnimateCamera(cp)
  End If
End Sub

My package name:

B4X:
com.testmaps.wekell

My 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: http://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="14"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
AddManifestText( <permission
          android:name="$PACKAGE$.permission.MAPS_RECEIVE"
          android:protectionLevel="signature"/>
      <uses-feature android:glEsVersion="0x00020000" android:required="true"/>)
 
AddManifestText( <permission
          android:name="$PACKAGE$.permission.MAPS_RECEIVE"
          android:protectionLevel="signature"/>
      <uses-feature android:glEsVersion="0x00020000" android:required="true"/>)
 
AddApplicationText(<meta-data
    android:name="com.testmaps.wekell"
    android:value="XXXXSyB18JvF0DUO3PmiurALqC5kTBemWH07MAQ"/>)
'End of default text.

My key online:

B4X:
Key for Android apps (with certificates)
API key:   
XXXXSyB18JvF0DUO3PmiurALqC5kTBemWH07MAQ
Android apps:   
XX:XX:XX:XX:DD:0F:2E:E0:94:B6:D3:61:5B:1B:2B:D8:F0:B3:88:8D;com.testmaps.wekell

And yes the numbers and letters replaced by XXXX do match. Whenever I sign my app and load it up on my Nexus 5 from B4A bridge it instantly crashes. What am I doing wrong?
 

DonManfred

Expert
Licensed User
Longtime User
Post the error log after the app crashes. There must be more infos
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
You're not including the new required manifest entry for com.google.android.gms.version, and also not including the Google Play Services android resources folder res which requires use of the new #AdditionalRes attribute.

Take a look at the tutorial which has been recently updated to show these extras steps required: http://www.b4x.com/android/forum/threads/google-maps-android-v2-tutorial.24415/.
Steps 5 and 6 show the manifest entry and AdditionalRes entry.

Without the com.google.android.gms.version integer entry in the manifest your app is likely to crash as described.

Martin.
 
Upvote 0

alexwekell

Member
Licensed User
Longtime User
You're not including the new required manifest entry for com.google.android.gms.version, and also not including the Google Play Services android resources folder res which requires use of the new #AdditionalRes attribute.

Take a look at the tutorial which has been recently updated to show these extras steps required: http://www.b4x.com/android/forum/threads/google-maps-android-v2-tutorial.24415/.
Steps 5 and 6 show the manifest entry and AdditionalRes entry.

Without the com.google.android.gms.version integer entry in the manifest your app is likely to crash as described.

Martin.

I had a version that was under 3.20 so I couldn't use that AdditionalRes entry.

I have however fixed it, my manifest was incorrect and I was accidentally using the V3 API.
 
Upvote 0
Top