title: Android java.lang.NoSuchFieldError
body: <p>In some case, when accessing an activity field from an anonymous class, I get NoSuchFieldError at runtime: <em>java.lang.NoSuchFieldError: MyActivity.myField</em></p>
  
  <p><strong>EDIT:</strong> I'm now sure that it's an Android issue, because everything compiles correctly but resolved incorrectly at runtime. When changing to <em>MyActivity.this.myField</em> instead of plain <em>myField</em>, everything works perfect.</p>
  
  <p>BTW, I rechecked and I don't have any other myField anywhere else, Also, when opening declaration in Eclipse, it goes to the intended field (<em>myField</em>).</p>
  
  <p>The only problem is that I couldn't reproduce this in a sample project. I'm left only to state that it's a specific problem in my project, but I'm reluctant doing so and I can't publish this project.</p>
  
  <p>I'll keep this open in case someone stumbles upon something similar.</p>
  
  <p><strong>Here's the code that I can publish that crashes my project but not the sample one:</strong></p>
  
  <pre><code>@Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      new Runnable() {
          @Override
          public void run() {
              Toast.makeText(MyActivity.this, myField.getName(), Toast.LENGTH_SHORT).show();
          }
      }.run();
  }
  </code></pre>