Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

How to obfuscate code in Android?

Hi, I am developing an Android app that consumes an API via a web service, sending a key to get information from the API, but if someone decompiles my application could use this key (which is a string) and extract all the information from the API. I have noticed that there are ways to obfuscate the code but there are also tools to de-obfuscate, so I wonder, what would be the best way to protect someone unauthorised retrieve data from the API?

2 Answers

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

The short answer is you can use the built-in tool Proguard to obfuscate code, but this is a hard problem. Here's a pretty good answer on StackOverflow that talks about some potential solutions and tradeoffs. Obfuscation alone won't change hard-coded strings.

Ben Jakuben have you try Dexguard?

Ben Jakuben
Ben Jakuben
Treehouse Teacher

No, I haven't. Have you used it? Any feedback? Looks promising, but I'll see if anybody has any opinions about it.