I'm currently working on an Android project, and learning how to use git. I'm blocked because of a problem with git : I have my Google Maps api key declared in my android-manifest file :
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="HEREISMYKEY"/>
Now, I'd like to push my code in github, but I can't push my AndroidManifest, because it contains my api key (which is supposed to remain secret).
I'd like to know if there is a way to modify it before every push, or maybe modify it each time I compile my application?
Thank you for your help !
The Android manifest file is a specially formatted XML file. You can edit the XML manually by clicking on the AndroidManifest. xml tab. Android manifest files generally include a single <manifest> tag with a single <application> tag.
If you're using Play App Signing instead, you must go to the app signing page on the Play Console to get your certificate fingerprint. Go to the Google Maps Platform > Credentials page. Select the API key that you want to set a restriction on. The API key property page appears.
xml file is created in the app's corresponding dist folder. The file is located at WorkspaceName>/temp/<AppName>/build/luaandroid/dist. The manifest file provides essential information about your app to the Android operating system, and Google Play store.
Create a new *.xml file in your res/values (call it api-keys.xml
or something similar).
Change your manifest to point to this string:
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="@string/GoogleMapsKey"/>
When you first push your changes to the public, put in a dummy key.
Then edit the file with your real API key.
Then add the file to your .gitignore file so it doesn't get pushed again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With