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?
Question posted in Android Studio
The official documentation can be found here.
The official documentation can be found here.
2
Answers
The simple answer is no you can’t. You have to store App Id somewhere in the string and set it in the manifest as you can’t change it on the run-time.
The best thing you can do is, store ad ids in the native c++ and retrieve them on runtime.
Someone can still find your ad ids, but it’s harder than finding them from the dex classes or string XML, as they show them as plain text.
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:
When you add the plugin you need write in
local.properties
the admob app id like thisFinally in the
manifest
put the variable with this format:And that’s it’s all, the app working with hiding admob id