title: Proguard Optimization Settings: Enabling class merging, casts and field/* in modern API and Proguard versions
body: <p>I've been obfuscating my apps for a long while, with the following settings I took like mantras, because they were Google's recommendations</p>
  
  <pre><code>-optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*
  </code></pre>
  
  <p>However, the other day I commented this line by mistake, the app got built correctly, and "apparently" works. I've made a lot of tests and couldn't made it crash.</p>
  
  <p>So I wonder if those disabled optimization settings are needed ... </p>
  
  <ul>
  <li><strong>as of today's Android SDK and latest Proguard versions</strong>, I only target devices from Android 4.0.3 onwards (15), and use Proguard 5.1.</li>
  <li>and for applications that don't do exotic stuff and have a properly written <code>proguard.cfg</code> instructing to keep the relevant problematic classes, etc. </li>
  </ul>
  
  <p>Most answers here releated to this very issue have conflicting information, and are related to pretty old API versions.</p>
  
  <p>One by one:</p>
  
  <h3>!code/simplification/arithmetic</h3>
  
  <p>I found a discussion on  <a href="https://groups.google.com/forum/#!topic/android-developers/v_o0AQ7o8gI" rel="nofollow noreferrer">Google Groups</a> where they say that <code>simplification/arithmethic</code> is not needed for SDK's after Android Donut. I assume then, I can safely enable this optimization.</p>
  
  <h3>!class/merging/*</h3>
  
  <p>It looks like proguard makes a good job in my projects with this optimization turned on:</p>
  
  <pre><code>[proguard]   Number of vertically merged classes:         296
  [proguard]   Number of horizontally merged classes:       445
  </code></pre>
  
  <p>Are there other side effects besides the stack traces being incorrect? I mean, side effects related to the application crashing rather than to debug issues. I found <a href="https://stackoverflow.com/questions/11329637/is-merging-classes-with-proguard-recommended-on-android-dalvik">this related question</a> but it doesn't conclude wether it is safe or not.</p>
  
  <h3>!field/* and !code/simplification/cast</h3>
  
  <p>I read <a href="https://stackoverflow.com/questions/12112514/android-proguard-does-not-inline">in this question</a> answered by ProGuard's author that those were included to avoid bugs with older Proguard versions. So is it safe to activate them on Proguard 5.1?</p>