While I knew the quick fix was to simply obtain a new key based on my current debug certificate and insert it into the AndroidManifest.xml file. The problem, however, is that I had no easy way to switch between using keys for debug and release (other than by copying and pasting). But, looking at the result of the Google Maps Android API tutorial I noticed that there is a way to have separate code running when debugging verses when released. The key is using Gradle: https://developer.android.com/tools/building/configuring-gradle.html
Some tips on going through the material:
- At first it was not clear that there is a pulldown just above the list of files that allows one to change views of the folder hierarchy, e.g,. Android vs. Project. In Android view, one only sees the files relevant to the build variant one is working on.
- In working through the example, I missed the step where one copies demo to full. I mistakenly copied the moved files back in to the main folder hierarchy. Interestingly, having duplicate xml files seemed to be fine, but having duplicate classes caused compile errors (has to do with how Gradle handles different types of items).
- While this example walks one through a fairly non-intuitive process of creating flavors, it does not address build types (e.g,. debug vs. release). Based on what learned, one can interpret the Gradle manual on build variants: http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants. In particular, creating a folder as app/src/demo to hold any general debug specific items and app/src/demoDebug for any flavor specific ones.
In this particular case the solution was to create two files:
- src/debug/res/values/google_maps_api.xml
- src/main/res/values/google_maps_api.xml
Then we can pull in the string value in AndroidManifest.xml based on whether are running as debug or release.
No comments:
Post a Comment