Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
86 views
in Technique[技术] by (71.8m points)

Obfuscation in Android Studio

Is there any obfuscation tool to use with Android Studio? IntelliGuard plugin is declared to be supported by the Studio, but it doesn't work actually due to missing AntSupport plugin. I wan't able to find one in the repository. Any ideas?

P.S. Android Studio build process is based on Gradle, so I wouldn't expect to see Ant support there at all. May be I'm wrong.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
  • Basic Obfuscation

To obfuscate code in Android studio just go to your build.gradle file in your Android Studio project:

enter image description here

Change the minifyEnabled property from false to true

enter image description here

This is a basic Obfuscation.

After generating the apk you can see the obfuscation result by decompiling the apk with any software. This page could help you:

http://www.decompileandroid.com/

In the obfuscation result you will see classes with name: a,b,c....

enter image description here

And the obfuscation variables and methods will have also names like aa,c,ac...

enter image description here

  • Normal obfuscation:

To obfuscate the code in a more complex form you could go to your root directory app and create a .pro file. For example in the following picture I have created the file: proguard-rules-new.pro. In the same directory you should see a file called proguard-rules.pro

enter image description here

Now add the file you have created to the build.gradle file

enter image description here

And edit the .pro file you have create with your own custom proguard rules

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...