You can set sensitive string in your gradle.properties
https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_properties_and_system_properties
For example:
in your gradle.properties
(usually located in your root project), you can define:
SERVICE_LINK = "mywebservicelink"
Then in your application's build.gradle
android {
...
defaultConfig {
resValue "string", "service_link", SERVICE_LINK
}
...
}
Then, this service link will be ready in your resource as R.string.service_link
. That is, you can simply get the value by doing:
getString(R.string.service_link);
EDIT 1:
If you're asking about how to hide your strings in your APK, then you can use ProGuard.
However, be advised. Whatever you put into your source code, there's no 100% guarantee that it cannot be reverse-engineered.
ProGuard will obfuscate your code, which will make reverse-engineering harder significantly.
For more information, this thread is awesome:
How to avoid reverse engineering of an APK file?