简体   繁体   English

如何通过在 android studio 中使用混淆 [proguard] 来保护我们的应用程序

[英]how to protect our app by using obfuscation[proguard] in android studio

I am searching for protecting my app by using proguard but I didnt find proper answer how to protect my app.我正在寻找使用 proguard 来保护我的应用程序,但我没有找到如何保护我的应用程序的正确答案。 If any body know how to protect our app using obfuscation in proguard help me.如果有人知道如何在 proguard 中使用混淆来保护我们的应用程序,请帮助我。

If you are using Android Studio如果您使用的是 Android Studio

  1. Go to build.gradle file of your app转到您的应用程序的 build.gradle 文件
  2. Check for below snippet in the file检查文件中的以下片段

Put minifyEnabled as 'true';将 minifyEnabled 设为 'true';

buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'),
                                                 'proguard-rules.pro'
        }
}
  1. In proguard-rules.pro add excpetions and rules matching your app.在 proguard-rules.pro 中添加与您的应用程序匹配的例外和规则。

Eg例如

-keep public class * extends android.support.v7.app.ActionBarActivity
-keep public class * extends your.package.name.SomeClass
-keep class android.support.v7.** { *; }
-keep interface android.support.v7.** { *; }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM