title: Android: Proguard NoSuchMethodError
body: <p>I recently activated ProGuard for my Eclipse Android project. After adding external libs and dynamically referenced classes to the proguard.cfg, I don't get any errors when building the apk. I get however a NoSuchMethodError when I try to start the installed app.</p>
  
  <p>I narrowed it down to a specific method called in the onCreate method of the main activity. To simplify things, here's what the class and method look like (I left out a lot of code, but I think this should illustrate it):</p>
  
  <pre><code>public class TestMain extends TabActivity implements OnSharedPreferenceChangeListener{
      ...
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          ...
          testMethod();
      }
  }
  </code></pre>
  
  <p>testMethod() is defined as follows:</p>
  
  <pre><code>private void testMethod() {
      int charsLeft = maxPostMessageLength - someEditText.length();
      ...
  }
  </code></pre>
  
  <p>When I remove the "someEditText.length()" part, the app starts. So, the way I see it, the method that can't be found is the EditText.length() method. Strangely, though, the app also starts when I remove "someEditText.length()" from the testMethod and put it directly into the onCreate method:</p>
  
  <pre><code>    @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          test = someEditText.length();
          testMethod();
      }
  </code></pre>
  
  <p>Does anyone know how I can get rid of this error and why I can call someEditText.length() directly in the onCreate method but not in a method called by the onCreate method?
  Without using Proguard the app works fine, of course.</p>
  
  <p>Edit:
  I tried the -dontshrink, -dontobfuscate and the -dontoptimzie options in the proguard.cfg. With -dontoptimize the app starts without errors.
  Still, it would be interesting what exactly causes this specific error.</p>