0

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 ?

M. Johnson
  • 839
  • 6
  • 13
  • 22

1 Answers1

2

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
        }
    }
Ahmad Nemati
  • 309
  • 2
  • 12
  • 1
    I've tried like your answer, and decompile in http://www.javadecompilers.com/apk but still not working – M. Johnson Apr 04 '18 at 08:04
  • are you trying build apk in debug mode?please get release mode see this link https://stackoverflow.com/questions/19619753/how-to-build-a-release-apk-in-android-studio – Ahmad Nemati Apr 04 '18 at 08:07
  • can you remove all progurad-rules.pro content and test it again?maybe your rules effect it – Ahmad Nemati Apr 04 '18 at 08:14
  • i try remove proguard except library proguard but still not working, because if i remove library proguard, can't generate apk, have error – M. Johnson Apr 04 '18 at 08:19
  • thanks @ahmad, after i try again working, the problem proguard of library, i remove all `-keep` but `dontwarn lib` not removed, but have another problem, app crash when running after proguard library `removed` – M. Johnson Apr 05 '18 at 04:01
  • so now you find what is problem i suggest you to use this link https://github.com/yongjhih/android-proguards for add exactly proguard rules that you need – Ahmad Nemati Apr 05 '18 at 05:07