79188955

Date: 2024-11-14 13:33:56
Score: 0.5
Natty:
Report link

@Kushal Billaiya's solution didn't work for me, as it overrides existing manifestPlaceholders. What I did instead was the following:

First, still set your Google Maps API Key as an environment variable named MAPS_API_KEY. I do this via the run configuration, but other ways exist.

Then in the android/app/build.gradle file (Important: There are 2 build.gradle files. You want the one inside the android > app folder), add one line to the defaultConfig:

defaultConfig {
    ...
    manifestPlaceholders["mapsApiKey"] = "$System.env.MAPS_API_KEY"
}

And in the android/app/src/main/AndroidManifest.xml file, you can add this line inside the <application> tag:

<meta-data android:name="com.google.android.geo.API_KEY" android:value="${mapsApiKey}"/>
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @Kushal
  • Low reputation (0.5):
Posted by: timlg07