I want to hide my AdMob App ID and Ad unit ID from the version control. I have tried making a separate file to store keys and then reading that file in java. But since I have to use App ID in Android Manifest, I can't do that. How do I achieve this?
Old question, but I found a nice solution.
You can use secrets gradle plugin for android develop by google, this plugin has been designed for google maps api key, but you can use with whatever key that you want to hide.
There are some warning too:
DISCLAIMER: This plugin is primarily for hiding your keys from version control. Since your key is part of the static binary, your API keys are still recoverable by decompiling an APK. So, securing your key using other measures like adding restrictions (if possible) are recommended.
When you add the plugin you need write in local.properties the admob app id like this
ADMOB_APP_ID="ca-app-pub-XXXXXX~XXXXX"
Finally in the manifest put the variable with this format:
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="${ADMOB_APP_ID}" />
And that's it's all, the app working with hiding admob id
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