1

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?

Ooto
  • 961
  • 13
  • 32

1 Answers1

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
  • 2
    You 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
  • @Rhen Thanks for good resource. I think this way can solve my problem – Ooto Feb 17 '19 at 12:44