Closed bramley-turner-stride closed 6 years ago
Correction: the google-services plugin does not write maps/geo api key to manifest.
If consumers of the LP lib are defining the newer com.google.android.geo.API_KEY
key in their manifest, they will get this error when you try to open a map:
java.lang.RuntimeException: Unable to start activity ComponentInfo{au.com.myapp.dev/au.com.myapp.activity.MapPickerActivity}: android.view.InflateException: Binary XML file line #15: Binary XML file line #15: Error inflating class fragment
...
Caused by: android.view.InflateException: Binary XML file line #15: Binary XML file line #15: Error inflating class fragment
Caused by: android.view.InflateException: Binary XML file line #15: Error inflating class fragment
Caused by: java.lang.RuntimeException: The API key can only be specified once. It is recommended that you use the meta-data tag with the name: com.google.android.geo.API_KEY in the <application> element of AndroidManifest.xml
Hi @bramley-turner-stride,
We're looking into this one.
Hi @bramley-turner-stride,
After reviewing this one, your assumptions are correct, as you can only have one API Key, and the correct place to put it would either int the AndroidManifest.xml or the google_maps_api.xml, we're checking with our R&D the possibility of changing this integration to follow Google Implementation.
The workaround for now would be to remove the API Key from both the AndroidManifest and the google_maps_api file, and include that one as a String under values/strings using the <string name="lp_google_maps_key">API_KEY</string>
tag, that would let you use it without the crash.
Hi @bramley-turner-stride .
I'm closing this issue, if you have any more questions related to this feel free to reopen it, or create a new one for any new issues.
We're working on a new way to handle Google Maps Key.
I get the following error:
This is because I explicitly include my Google Maps API key in my app's manifest (I use maps for other purposes unrelated to LP in my app).
The messaging_ui.aar lib declares it's own maps API key in its manifest:
@string/lp_google_maps_key
is empty, by the way.While for me, the solution is simple (add
tools:replace
as the error message suggests), other consumers of this library could have much worse problems: -The google-services plugin, which applies the settings in the google-services.json file, is overrridden by the values in messaging_ui, without warning or error. This is true even for your own sample app. I have added some code to demonstrate the API key is empty in my fork of the sample. See here: https://github.com/bramley-turner-stride/Android-Messaging-SDK/commit/1093f881479750d8b694f4d76e7b9b9c754c1b58 . Run the app, and look at the footer text. It will show Maps API key: '' (empty string) -Consumers of this lib may be using the newercom.google.android.geo.API_KEY
geo key instead. I'm not sure how the maps SDK handles having two conflicting API keys present in the manifest.