title: When can BuildConfig.VERSION_CODE return wrong int
body: <p>When i set the <code>versionCode</code> to 2 the app still report it to be 1.
  When I set the <code>versionCode</code> to 3 the app detect that.
  alo 5, 6 but not setting:</p>
  
  <pre><code>defaultConfig {
      versionCode 2
  </code></pre>
  
  <p>Is not working with the number 2, I have cleaned the project and rebuilt but still same result.</p>
  
  <p>What am I missing?</p>
  
  <p>I want to detect when a new app version is released with this piece of Firebase code: Note that I run this in debug in Android Studio</p>
  
  <pre><code>ValueEventListener systemListener = new ValueEventListener() {
              @Override
              public void onDataChange(DataSnapshot dataSnapshot) {
                  App app = dataSnapshot.getValue(App.class);
                  if (app.getVersionCode() &gt; BuildConfig.VERSION_CODE) {
                      SettingsManager.setForceAppUpdate(true);
                      for (OnForceAppUpdateListener l : Application.getInstance()
                              .getUIListeners(OnForceAppUpdateListener.class))
                          l.onForceAppUpdate();
                  } else { // TODO for testing
                      SettingsManager.setForceAppUpdate(false);
                      for (OnForceAppUpdateListener l : Application.getInstance()
                              .getUIListeners(OnForceAppUpdateListener.class))
                          l.onForceAppUpdate();
                  }
              }
  
              @Override
              public void onCancelled(DatabaseError databaseError) {
  
              }
          };
  </code></pre>
  
  <p>And when I went from versionCode 1 to versionCode 2 I notis the above <code>BuildConfig.VERSION_CODE</code> being 1</p>
  
  <p>I also try this:</p>
  
  <pre><code>Application.getInstance().getPackageManager()
  .getPackageInfo(Application.getInstance()
  .getPackageName(), 0).versionCode;
  </code></pre>
  
  <p>Also return 1 for versionCode</p>