M. Johnson
M. Johnson

Reputation: 839

Obfuscate code not working in android

i want to obfuscate my android code, i have set minifienable true and setup proguard file, but after generate apk and decompile, code not obfuscate. This is my proguard :

#START
# This is a configuration file for ProGuard.
# http://proguard.sourceforge.net/index.html#manual/usage.html
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose

-optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*
-optimizations !method/inlining/*
-optimizationpasses 5
-allowaccessmodification

-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends com.actionbarsherlock.app.SherlockListFragment
-keep public class * extends com.actionbarsherlock.app.SherlockFragment
-keep public class * extends com.actionbarsherlock.app.SherlockFragmentActivity
-keep public class * extends android.app.Fragment
-keep public class com.android.vending.licensing.ILicensingService
#For native methods, see #http://proguard.sourceforge.net/manual/examples.html
#native
-keepclasseswithmembers class * {
    native <methods>;
}

-keep public class * extends android.view.View {
    public <init>(android.content.Context);
    public <init>(android.content.Context, android.util.AttributeSet); public <init>(android.content.Context, android.util.AttributeSet, int);
    public void set*(...);
}
-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * { public <init>(android.content.Context, android.util.AttributeSet,int);
}
-keepclassmembers class * extends android.app.Activity {
    public void *(android.view.View);
}
#For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations
-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
    public static final android.os.Parcelable$Creator *;
}
-keepclassmembers class **.R$* {
    public static <fields>;
}
-keep class android.support.v4.app.** {*;}
-keep interface android.support.v4.app.** {*;}
-keep class com.actionbarsherlock.** {*;}
-keep interface com.actionbarsherlock.** {*;}
#The support library contains references to newer platform versions.
#Don't warn about those in case this app is linking against an older
#platform version. We know about them, and they are safe.
-dontwarn android.support.**
-dontwarn com.google.ads.**
-keepclassmembers class * {
    @android.webkit.JavascriptInterface <methods>;
}
-keepattributes JavascriptInterface
-keepattributes *Annotation*
-dontwarn com.razorpay.**
-keep class com.razorpay.** {*;}
-keepclasseswithmembers class * {
    public void onPayment*(...);
}

#END
#MOCKITO
-dontwarn org.mockito.**

i have setup proguard library, I've tried to remove -keep but still not working. are there another setup to make obfuscate code ?

Upvotes: 0

Views: 2286

Answers (1)

Ahmad Nemati
Ahmad Nemati

Reputation: 319

it seems you are not enable progurad enable it by add this to your app build.gradle

buildTypes {
        release {
            debuggable false
            minifyEnabled true
            shrinkResources true
            useProguard true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
        }
    }

Upvotes: 2

Related Questions