Android: i want to create code very secure [closed

2019-06-14 21:03发布

My question is to develop one application in android, so meanwhile I want to create well secure code, I'm uploading APK in play store how to obfuscates my code using a Proguard, I need to obfuscate class names, libraries, id and basic functionalities in the Proguard.

Please help me to do how secure my code in a play store?

1条回答
淡お忘
2楼-- · 2019-06-14 21:29

Add these lines in build.gradle file in your module app file not project file

buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'),
                'proguard-rules.pro'
    }
    debug {
        minifyEnabled false
    }
}

And add these lines in proguard-rules.pro file

-dontwarn com.android.volley.toolbox.**
-keep class org.codehaus.** { *; }
-dontwarn android.support.v7.**
-keep android.support.v7.**
-dontwarn android.support.**
-keepattributes **
-keepattributes   Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,*Annotation*,EnclosingMethod


-keep class android.support.v4.app.** { *; }
-keep interface android.support.v4.app.** { *; }
-keep class android.support.v7.app.** { *; }
-keep interface android.support.v7.app.** { *; }
-keep class android.support.v13.app.** { *; }
-keep interface android.support.v13.app.** { *; }
-dontwarn android.support.design.**
-keep class android.support.design.** { *; }
-keep interface android.support.design.** { *; }
-keep public class android.support.design.R$* { *; }
-dontwarn org.apache.http.**
-dontwarn com.mixpanel.**
-dontwarn org.codehaus.jackson.**
-dontwarn org.acra.ErrorReporter.**
-dontwarn com.jeremyfeinstein.slidingmenu.**
-keepnames class com.fasterxml.jackson.** { *; }
-keepclassmembers public final enum     

Please note do not forget to add external libraries in proguard rules else app will be crash and you will get NoClassDefFoundError exception

查看更多
登录 后发表回答