title: How do I make sure unsupported (higher level) API is not called in Android?
body: <p>I'm building an application for Gingerbread and up with <code>minSdkVersion=10</code> and <code>targetSdkVersion=17</code> in my AndroidManifest.xml.</p>
  
  <p>I know that I should check if the API is supported before I call it, for example:</p>
  
  <pre><code>private void removeRule(RelativeLayout.LayoutParams params, int rule) {
      if (android.os.Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.JELLY_BEAN_MR1) { // API 17
          params.removeRule(rule);
      } else {
          params.addRule(rule, 0);
      }
  }
  </code></pre>
  
  <p>But sometimes I forget/or don't know I'm calling a higher level API and occasionally crash my program with <code>NoSuchMethodError</code> exception.</p>
  
  <p>So before I publish my app, I always set my project to use Android SDK 2.3.3 and make sure I'm not making illegal method calls (e.g. all the errors I get are wrapped in an <code>if</code> statement checking the android SDK version), then set the SDK back to 4.2.2.</p>
  
  <p>Is there a better way to make sure unsupported API is not called without switching the SDK?</p>
  
  <p>(P.S. I'm using IntelliJ)</p>