sagar suri
sagar suri

Reputation: 4731

Proguard not obfuscating string and class names

This is the first time I am using proguard. I am able to obfuscate almost everything in my apk. But string and class names are not getting obfuscated. How can I make sure that class names gets obfuscated in my apk.

Here is my proguard-rule.pro

-assumenosideeffects class android.util.Log {
   public static boolean isLoggable(java.lang.String, int);
   public static int v(...);
   public static int i(...);
   public static int w(...);
   public static int d(...);
   public static int e(...);
}
-dontwarn org.androidannotations.api.rest.**
-keep class com.github.mikephil.charting.** { *; }
-dontwarn android.support.v7.**
-keep class android.support.v7.** { *; }
-keep interface android.support.v7.** { *; }
-dontwarn com.squareup.okhttp.**
-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public enum com.bumptech.glide.load.resource.bitmap.ImageHeaderParser$** {
  **[] $VALUES;
  public *;
}

This is my build.gradle file:

android {
    compileSdkVersion 25
    buildToolsVersion '25.0.2'

    defaultConfig {
        applicationId "com.ignite.tsa"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
        }
    }
    dexOptions {
        preDexLibraries = false
        javaMaxHeapSize "4g" // 2g should be also OK
    }
}

What am I doing wrong ? Can someone provide with a proper proguard-rule.pro file for obfuscating the AppCompat and other android libraries present.

Upvotes: 1

Views: 1316

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006564

I am able to see the appcompat files easily

Well, sure. You typed into your ProGuard rules the following lines:

-keep class android.support.v7.** { *; }
-keep interface android.support.v7.** { *; }

If you want classes in android.support.v7 to be obfuscated (and removed if they are unused), you need to get rid of those lines, or replace them with something that is better tailored to indicate specifically what you want to keep.

Upvotes: 1

Related Questions