title: Proguard Capabilities and Configuration
body: <p>I have some questions about Proguard configuration:</p>
  
  <ol>
  <li>Why Proguard doesn't obfuscate my class with these code?</li>
  </ol>
  
  <p><strong>Java</strong></p>
  
  <pre><code>public static String encrypt(String keyString, String text) {
      try {
          Cipher cipher = Cipher.getInstance(...);
  
          ...
  
          byte[] key = new byte[...];
          ...
          SecretKeySpec keySpec = new SecretKeySpec(key, ...);
  
          byte[] encrypted = cipher.doFinal(text.getBytes(...));
  
          return ...
  
      } catch (Exception e) {
          e.printStackTrace();
      }
      return null;
  }
  </code></pre>
  
  <p><strong>build.gradle</strong></p>
  
  <pre><code>buildTypes {
      release {
          minifyEnabled true
          proguardFiles 'proguard-rules.pro'
      }
      debug {
          signingConfig signingConfigs.config
      }
  }
  </code></pre>
  
  <p><strong>Proguard</strong></p>
  
  <pre><code># This is a configuration file for ProGuard.
  # http://proguard.sourceforge.net/index.html#manual/usage.html
  
  -dontusemixedcaseclassnames
  -dontskipnonpubliclibraryclasses
  -verbose
  
  # Optimization is turned off by default. Dex does not like code run
  # through the ProGuard optimize and preverify steps (and performs some
  # of these optimizations on its own).
  -dontoptimize
  -dontpreverify
  -keepclassmembers class **.R$* {public static &lt;fields&gt;;}
  -keep class **.R$*
  -keepattributes JavaScriptInterface
  
  # If you want to enable optimization, you should include the
  # following:
  # -optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*
  # -optimizationpasses 5
  # -allowaccessmodification
  #
  # Note that you cannot just include these flags in your own
  # configuration file; if you are including this file, optimization
  # will be turned off. You'll need to either edit this file, or
  # duplicate the contents of this file and remove the include of this
  # file from your project's proguard.config path property.
  
  -keepattributes *Annotation*
  
  # For native methods, see http://proguard.sourceforge.net/manual/examples.html#native
  # -keepclasseswithmembernames class * {
  #    native &lt;methods&gt;;
  # }
  
  -assumenosideeffects class android.util.Log {
      public static int d(...);
      public static int v(...);
      public static int i(...);
      public static int w(...);
      public static int e(...);
  }
  
  -keep public class * extends android.view.View {
      public &lt;init&gt;(android.content.Context);
      public &lt;init&gt;(android.content.Context, android.util.AttributeSet);
      public &lt;init&gt;(android.content.Context, android.util.AttributeSet, int);
      public void set*(...);
  }
  
  -keepclassmembers enum * {
      public static **[] values();
      public static ** valueOf(java.lang.String);
  }
  
  -keepclassmembernames class * implements android.os.Parcelable {
    public static final android.os.Parcelable$Creator *;
  }
  
  -keepclassmembers class **.R$* {
      public static &lt;fields&gt;;
  }
  
  # 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.**
  </code></pre>
  
  <p>What could be wrong to prevent my code to be obfuscated?</p>
  
  <ol start="2">
  <li><p>What I learn is, do not obfuscate <strong>Activity</strong> and <strong>Fragment</strong> using Proguard, am I right?</p></li>
  <li><p>Proguard does not able to obfuscate <code>strings.xml</code> and instead replace the strings to the Java code?</p></li>
  </ol>