Android Question Found multiple <meta-data> elements for key 'com.google.android.gms.version', expected at most one.

RichardN

Well-Known Member
Licensed User
Longtime User
Getting the error above when uploading my App Bundle to Google Play. I see several other users have had similar issues but usually caused by duplicate manifest entries, in this case I cannot see any duplicates. I have tried commenting out suspect manifest entries but that only gives me a white Google map every time. Unsure of how to progress this further....

Attributes:
#Region  Project Attributes

    '..................................
    #MultiDex: True
    #AdditionalJar: com.android.support:support-v4
    #AdditionalJar: com.google.android.gms:play-services-location
    
    #Extends: android.support.v7.app.AppCompatActivity
    
#End Region

Manifest:
AddManifestText(
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="33"/>
<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, FirebaseAnalytics.GooglePlayBase)
    
AddApplicationText(
<meta-data
  android:name="com.google.android.geo.API_KEY"
  android:value="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"/>)
 
AddApplicationText(
<uses-library
      android:name="org.apache.http.legacy"
      android:required="false"/>)

SetApplicationAttribute(android:theme, "@style/MyAppTheme")

CreateResource(values, theme.xml,
<resources>
    <style name="MyAppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="colorPrimary">#0098FF</item>
        <item name="colorPrimaryDark">#007CF5</item>
        <item name="colorAccent">#AAAA00</item>
        <item name="windowNoTitle">true</item>
        <item name="windowActionBar">false</item>
    </style>
</resources>
)

AddApplicationText(<meta-data
    android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version" />)
 

DonManfred

Expert
Licensed User
Longtime User
guess you can remove

AddApplicationText(<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />)
as it is already added by
B4X:
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
 
Upvote 1

DonManfred

Expert
Licensed User
Longtime User
B4X:
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
will add
B4X:
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="@integer/google_play_services_version" />
)
to your manifest.

a white map sounds more like an invalid api.key
 
Upvote 0

RichardN

Well-Known Member
Licensed User
Longtime User
a white map sounds more like an invalid api.key
@DonManfred api.key? Normally I would agree with you but the map is working perfectly in both Debug + Release on 2 different devices, so it's not that.

I tried fudging a solution by removing:
Manifest:
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)

'And replaced it with an edited version of your 2nd example......

AddApplicationText(
   <activity android:name="com.google.android.gms.common.api.GoogleApiActivity"
  android:theme="@android:style/Theme.Translucent.NoTitleBar"
  android:exported="false"/>

When I uploaded the resulting .aab to the Store it reports no error. Unfortunately in that configuration the Google Map element does not work - White Map. There must be some other element that is giving rise to multiple declarations.
 
Upvote 0

RichardN

Well-Known Member
Licensed User
Longtime User
Another day.... and all devices rebooted, app deleted and re-installed. With my original manifest (as the first post) and another re-compile of the app the Google Map functionality has mysteriously returned. Uploading the .aab to the Play store no longer produces the original error about multiple declarations. I have absolutely no idea what was responsible.
 
Upvote 0
Top