Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android `templateMergeStrategy` in strings.xml

What does the templateMergeStrategy property mean in an Android resource?

e.g. in Google Maps API key file

<string name="google_maps_key" templateMergeStrategy="preserve" translatable="false">
    AIza.......some...secret...key...
</string>

I would have expected a simple google (or duckduckgo) search to give me results, but unfortunately it only seems to give me Google Maps API questions.

Unfortunately the Android Developer Docs on "String Resources" are also lacking in that department.

like image 367
Richard Le Mesurier Avatar asked Nov 20 '15 06:11

Richard Le Mesurier


People also ask

How to add special characters in string XML in Android?

How can I write character & in the strings. xml? In android studio, you can simply press Alt+Enter and it will convert for you.

What is the use of strings XML file in Android?

A string resource provides text strings for your application with optional text styling and formatting. There are three types of resources that can provide your application with strings: String. XML resource that provides a single string.


2 Answers

From change log

Uses this to overwrite the instructions in the Google Maps template. Subsequent runs of the template always update the instructions with the user's current keystore credentials.

Also changed the Maps instructions to deep link into a Google developer console flow, which allows for easier key generation.

like image 106
Pankaj Kumar Avatar answered Oct 17 '22 14:10

Pankaj Kumar


It means Android Studio template engine will preserve this line when a new Google Maps Activity is created, so you don't loose your key.

like image 39
Marcelo Liberato Avatar answered Oct 17 '22 14:10

Marcelo Liberato