aimqqroad-13

这一篇说一下Android Studio的代码混淆:

第一步:要想使混淆生效,要修改项目(App)下的build.gradle一处内容:minifyEnabled  的值 设置为true,当前项目就可以使用混淆了。

apply plugin: \'com.android.application\'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.0"
    defaultConfig {
        applicationId "com.aimqq.andfixdemo"
        minSdkVersion 15
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled true   //这里设置为true 表示使用混淆   false表示禁用混淆
            proguardFiles getDefaultProguardFile(\'proguard-android.txt\'), \'proguard-rules.pro\'
        }
    }
}

dependencies {
    compile fileTree(dir: \'libs\', include: [\'*.jar\'])
    androidTestCompile(\'com.android.support.test.espresso:espresso-core:2.2.2\', {
        exclude group: \'com.android.support\', module: \'support-annotations\'
    })
    compile \'com.android.support:appcompat-v7:24.1.1\'
    testCompile \'junit:junit:4.12\'
    compile \'com.alipay.euler:andfix:0.3.1@aar\'
}

第二步:定义我们自己的混淆规则:

① 让混淆规则只在当前项目生效,我们只需要在项目的proguard-rules.pro文件中添加规则即可。

② 如果你想是你自己定义的混淆规则在以后所有的项目都生效,那么你需要去你SDK的目录下\tools\proguard\proguard-android.txt进行修改,添加相应的混淆规则。

 

如果想了解更多关于混淆的知识、语法,请参考这一博客:

  http://blog.csdn.net/u011889786/article/details/50945693

分类:

技术点:

相关文章:

  • 2021-12-31
  • 2021-08-24
  • 2022-12-23
  • 2021-04-27
  • 2021-10-22
  • 2021-08-09
  • 2021-05-22
  • 2021-11-15
猜你喜欢
  • 2021-09-17
  • 2021-09-16
  • 2021-09-26
  • 2021-04-03
  • 2021-09-28
  • 2021-10-12
相关资源
相似解决方案