views:

51

answers:

2

My application uses a large number of MapView screens and I'm trying to figure out how to manage the API key between the debug environment and production. Apparently, there is no way to change the debug application key in Eclipse so I must use a debug map API key in that environment. Conversely, there is no way to export a package for beta testing without a production application key so I must change the map API key in every view in order to create a working package.

My first idea was to do this:

All MapView.xml files have this:

android:apiKey="@string/googleMapsAPIKey"

And then in strings.xml I put this:

@string/debugGoogleMapsAPIKey TheMagicKeyString

If this worked, it would allow me to change a single line in strings.xml and all the MapViews would get updated in the rebuild. But it didn't work. I guess strings.xml can't make references into itself. Any other ideas?

Thanks

A: 

you are doing the right thing but not the right way I think. Declare your string in strings.xml like this :

<string name="googleMapsAPIKey">TheMagicKeyString</string>
<!-- You can add this at the end as comment to keep a copy of another key for instance, to exchange it between debug and production-->

Note that you didn't give the same name at your 2 strings... One is called debug and not the other.

Sephy
Well, that's not too bad a way to do it. I think I'll use this approach until the Android/Google/Eclipse team comes up with more automation.
A: 

You can set custom debug keystore in Prefs window -> Android->Build.

Rabas
Here's the info about that from the Android docs: "If necessary, you can change the location/name of the debug keystore/key or supply a custom debug keystore/key to use. However, any custom debug keystore/key must use the same keystore/key names and passwords as the default debug key (as described above). (To do so in Eclipse/ADT, go to Windows > Preferences > Android > Build"Note that you can use a custom keystore but you have to use the same password as the default. That won't really help.