Android Question Setting up google maps

kostefar

Active Member
Licensed User
Longtime User
Dear All,

I´ve done all that´s written here:

https://www.b4x.com/android/forum/threads/google-maps.63930/#post-404386

But still suffer from the error below:

java.lang.NoClassDefFoundError: com.google.android.gms.maps.MapFragment

which occurs when trying to open an activity with the mapfragment.

So I went to look at where my SDK is installed, which is also the path to which b4a points:

F:\android\sdk\extras\google\google_play_services

Clear significance of activity there after updating, since the files and folders are dated today, but the only ones found are the folders docs, samples, and the file source.properties.
I´m not sure if that´s the problem, and I´ve read somewhere that with more recent versions of android, google play services installs in another way in the m2repository folder.

My manifest looks like this:

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="14" android:targetSdkVersion="21"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
SetApplicationAttribute(android:theme, "@android:style/Theme.Holo")
'End of default text.
AddManifestText(
<uses-permission
  android:name="android.permission.WRITE_EXTERNAL_STORAGE"
  android:maxSdkVersion="18" />
)
'************ Google Play Services Base ************
AddApplicationText(
   <activity android:name="com.google.android.gms.common.api.GoogleApiActivity"
  android:theme="@android:style/Theme.Translucent.NoTitleBar"
  android:exported="false"/>
    <meta-data
  android:name="com.google.android.gms.version"
  android:value="8487000" />
)
'************ Google Play Services Base (end) ************
AddApplicationText(
<meta-data
  android:name="com.google.android.geo.API_KEY"
  android:value="AIz*(the rest of key removed)"/>
)
#AdditionalJar: com.google.android.gms:play-services-maps

The gms version I took from an older SDK folder in which I found the google maps folder and temporarily copied it to where the active SDK is located, but with the same result.

Before retrieving the key, I indeed enabled google maps android API.
Finally, I don´t know if it´s got anything to do with it, but I´m using the memu emulator and not the AVD. I tried once with the AVD, which told me that google play services had stopped upon launch, and when testing my app it crashed with the same error message as first mentioned.

What could be wrong?

Thanks in advance!
 

kostefar

Active Member
Licensed User
Longtime User
Are you using B4A v6+? If so then follow the B4A 6+ instructions: https://www.b4x.com/android/forum/threads/google-maps.63930/#post-404386

BTW, the Google Play Services Base snippet is wrong. You should copy it exactly as it is.

Thanks Erel, I did follow the instructions for 6+ but my mistake was to leave out:

B4X:
#AdditionalJar: com.google.android.gms:play-services-maps

.. in the code itself.

I inserted that and changed the version value back to the "integer" one mentioned in the original snippet and now a map pops up so it seems all good.

Good stuff to begin the day with, thanks one more time! :)
 
Upvote 0
Top