Android Question Maven artifact not found: com.google.android.gms/play-services-maps

Jakes72

Member
Licensed User
Hi All,

Please could someone shed some light on this error:
Maven artifact not found: com.google.android.gms/play-services-maps

I have installed this with the SDK Manager (see screenshot).
What am I doing wrong? Sorry for the ignorance, but I am a complete noob with B4A.

Regards,
Jacques.
 

Attachments

Jakes72

Member
Licensed User
Hi Erel,

The value is:
C:\Program Files (x86)\Android\android-sdk\platforms\android-25\android.jar
 

Jakes72

Member
Licensed User
OK thank you Erel, I have changed it to that and it now compiles and runs, but I have a new problem now.
The minute I load the form (view) where I have my map fragment on, my app crashes.
It says I do not have something required in my manifest.

To try to help you solve this problem, here is my Project Attributes Region:

#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


Here is my manifest:

'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)

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

'End of default text.


Here is my Sub Globals:

Sub Globals


Private gmap As GoogleMap
Private MapFragment1 As MapFragment


End Sub



Sub MapFragment1_Ready
gmap = MapFragment1.GetMap
Dim m1 As Marker = gmap.AddMarker(10, 30, "test")
m1.Snippet = "This is the snippet"
End Sub
 

Jakes72

Member
Licensed User
Hi Erel,

This is the error message I get:

java.lang.IllegalStateException: A required meta-data tag in your app's AndroidManifest.xml does not exist. You must have the following declaration within the <application> element: <meta-data android:name="com.google.android.gms.version" android:value="@Integer/google_play_services_version" />
at com.google.android.gms.common.GooglePlayServicesUtilLight.isGooglePlayServicesAvailable(Unknown Source)
at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
at com.google.android.gms.maps.internal.zzbz.zza(Unknown Source)
at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
at com.google.android.gms.maps.MapFragment$zzb.zzc(Unknown Source)
at com.google.android.gms.maps.MapFragment$zzb.createDelegate(Unknown Source)
at com.google.android.gms.dynamic.DeferredLifecycleHelper.zaa(Unknown Source)
at com.google.android.gms.dynamic.DeferredLifecycleHelper.onCreate(Unknown Source)
at com.google.android.gms.maps.MapFragment.onCreate(Unknown Source)
at android.app.Fragment.performCreate(Fragment.java:2047)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:868)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1072)
at android.app.BackStackRecord.run(BackStackRecord.java:857)
at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1480)
at android.app.FragmentManagerImpl$1.run(FragmentManager.java:452)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5572)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:968)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:763)
 

Jakes72

Member
Licensed User
OK an update on my error, I changed my manifest to now look like this (not sure if this is correct):

'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)

AddApplicationText(
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyB_myZDlKkZBFVB-yxEbUI2YJNn9HIeGAc"
/>

<meta-data
android:name="com.google.android.gms.version"
android:value="@Integer/google_play_services_version"
/>

)

'End of default text.


If i run it now, I get this error:

B4A Version: 8.80
Parsing code. (0.00s)
Building folders structure. (0.01s)
Compiling code. (0.02s)
Compiling layouts code. (0.01s)
Organizing libraries. (0.00s)
Generating R file. Error
AndroidManifest.xml:32: error: Error: No resource found that matches the given name (at 'value' with value '@Integer/google_play_services_version').
 

Jakes72

Member
Licensed User
Hi Erel,

Thanks for your reply.
I have tried to follow that tutorial but I am going wrong somewhere.

These are the steps I have taken:

1. I have registered my app in Google developer console and received an API Key, and I have put an entry for this in the manifest, like this:

B4X:
AddApplicationText(

<meta-data
      android:name="com.google.android.geo.API_KEY"
      android:value="AIzaSyB_myZDlKkZBFVB-yxEbUI2YJNn9HIeGAc"
/>

<meta-data
    android:name="com.google.android.gms.version"
    android:value="16.0.0"
/>
 
)

I am not sure what value to use for com.google.android.gms.version, I assume 16.0.0 is correct?


2. You say we need to enable 'Google Maps Android API' but there is no API with this name that I can see, so I have enabled 'Maps SDK for Android', is this correct?

3. I have downloaded the attached Google Maps v2 and put it in my libraries folder and added it as reference to the project.

4. I added this code:

B4X:
#Region  Project Attributes
    'The name to display for the App.
    #ApplicationLabel: MrD          
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
    #AdditionalJar: com.google.android.gms:play-services-maps
#End Region

5. Now this is the part where I think I may be going wrong, you say I must add snippets from the Google Play Services Base URL you supply but I do not know on that site where to get the snippets from? I have registered with them and used the same project name as my app name, and all I get from them is a Project ID and Web API key and Public facing name which I am not sure what to do with? I downloaded the google-services.json file from them and put this also in my project root folder.
 

Jakes72

Member
Licensed User
Hi Erel,

Never mind I got it too work!
The problem was that I had 16.0.0 in below code as a value when I should have had "@Integer/google_play_services_version" as the value.
B4X:
<meta-data
    android:name="com.google.android.gms.version"
    android:value="16.0.0"
/>
Thank you very much sir for the help, it is greatly appreciated! I am sure to be back on here with more questions and hopefully this can help others too.
 
Top