Eric Mill wrote: > In my app, I'm taking advantage of a web-based API (the Sunlight Labs > API) that requires an API Key. The project is also open source, > hosted on Github. I want to avoid committing my API key into the > codebase. > > I'd be fine with creating some other .xml file of special string > values, and git-ignoring that file (while providing a .xml.example > file to copy into its place), but I don't know the best way of doing > that with the Android SDK. > > Any suggestions?
Total brainstorm, never tried this, your kilometerage may vary, etc. It also assumes you're using Ant... Step #1: Put the layout file containing the MapView element that needs the API key somewhere other than res/layout/ (e.g., make a layout-template/ directory and put it there). Step #2: Create an Ant target that reads in a property file and uses <copy> and <replaceregexp> tasks to "paste" the API key out of the property file into a copy of the layout you make in the proper spot (e.g., copy from layout-template/ to res/layout/ and then paste in the key). Step #3: git-ignore the post-API-key edition of the layout file and your property file. Step #4: Possibly have your Ant target turn around and call some other target (e.g., the debug target). Side benefit of this: you can have two targets and two property files, one for debug and one for production. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy _The Busy Coders' Guide to *Advanced* Android Development_ In Print! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

