自古英雄不问出处,奈何我却不是英雄!
转载请标明出处:http://blog.csdn.net/u011275767/article/details/46471935
由于adt的更新和IDE的变化代码混淆的配置文件也发生了变化,下面给大家说一下主要发生了什么变化。希望能帮到大家
Eclipse中老版本的ADT里面是proguard.cfg,然后在defult.properties加入proguard.config=proguard.cfg。defult.properties文件是这样的
- # This file is automatically generated by Android Tools.
- # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
- #
- # This file must be checked in Version Control Systems.
- #
- # To customize properties used by the Ant build system use,
- # "build.properties", and override values to adapt the script to your
- # project structure.
- # Project target.
- target=android-19
- proguard.config=proguard.cfg
新版ADT没有了proguard.cfg而是换成了project.properties和proguard-project.txt。其实没啥区别在project.properties加入proguard.config=proguard-project.txt。就可以了。proguard-project.txt文件是这样的。
这里要知道一个地方proguard.cfg是可以直接拿过来当proguard-project.txt用的。
- # This file is automatically generated by Android Tools.
- # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
- #
- # This file must be checked in Version Control Systems.
- #
- # To customize properties used by the Ant build system edit
- # "ant.properties", and override values to adapt the script to your
- # project structure.
- #
- # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
- # proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
- # Project target.
- target=android-19
- proguard.config=proguard-project.txt
新版ADT没下面说一下android studio的使用,到了android studio中又有了不同这回没有了proguard-project.txt变成了proguard-rules.txt其实就是名字变了而已。用法一样。不同的是studio中没有了eclipse里面的project.properties或者defult.properties。而是换成了build.gradle。build.gradle中有这么一段。只要把minifyEnabled 后面的false改为true就会执行混淆代码了。
- buildTypes {
- release {
- // minifyEnabled为true会执行proguard-rules.txt混淆代码
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
- }
- }
到此配置文件的不同就介绍完毕了