Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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.