I work in a team of several developers. We are developing an Android applicatio开发者_JS百科n that uses Google Maps. Since every one of us has different debug keystore, each of us has different API key. What is the best way to allow every developer (and build server) to automatically substitute his own key into the application when it is built?
You can follow the below process
in strings.xml
file add the following line
<string name="mapkey">your api key</string>
Use the following in your map xml
android:apiKey="@string/mapkey"
So the developer have to make change in strings.xml
file only.
Thanks Deepak
We used a properties file where we stored our key inside (saved that in assets/config.properties). The only issue with that is that you have to create the MapView programmatically and not in your xml because the api key can only be added dynamically in the constructor.
You can share your debug.keystore
file between your team. You can find it in root folder of your project. Eclipse doesn't override it if it already exists so you can use the same debug keystore as your mates. So you all will have the same Map API key.
精彩评论