I'm new to Android programing. I'm using retrofit2
to create an API. I'm now wondering if there is a way to hide API url defined as a static variable inside class.
I'd like to store the url inside string
folder if possible. Is there a way to do it?
Asked
Active
Viewed 477 times
1

Ooto
- 1,117
- 16
- 39
-
you can use proguard to ensure not finding url. – Muhaiminur Rahman Feb 17 '19 at 12:03
1 Answers
0
Hi I think the best way to do this in code level is to: - encrypt the variable url and decrypt it when you will use on retrofit instead of putting it on a res / raw file or string folder or xml.
- don't add httploggingInterceptor on retrofit when building a production apk
- always use pro guard on retrofit

Rhen
- 91
- 3
-
Hi I just want to hide url so other people cannot see this when I upload the project somewhere. Could you make what you are saying more clear? – Ooto Feb 17 '19 at 12:23
-
2You still can but not a good practice , try this solution https://stackoverflow.com/a/47942035 – Rhen Feb 17 '19 at 12:30
-
So you want to upload your project somewhere (for example, Github), but you don't want anyone to see your API base url? – Stanislav Shamilov Feb 17 '19 at 12:31
-
-