title: Lifecycle.addObserverUntilDestroy extension stopped working with AndroidX
body: <p>I've been using following Kotlin extension to add my lifecycle observers:</p>
  
  <pre><code>fun Lifecycle.addObserverUntilDestroy(observer: LifecycleObserver) {
      addObserver(observer)
  
      addObserver(object : LifecycleObserver {
          @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
          fun onDestroy() {
              removeObserver(this)
              removeObserver(observer)
          }
      })
  }
  </code></pre>
  
  <p>The idea was to automatically remove the observer when the Lifecycle is being destroyed.</p>
  
  <p>So I can call it in Activity's onPostCreate (in this case a Java code but it is the same when calling from Kotlin):</p>
  
  <pre><code>ArchitectureComponentExtensions.addObserverUntilDestroy(getLifecycle(), myViewModel);
  </code></pre>
  
  <p>And have this code in my ViewModel (a custom one, not the on from Architecture Components):</p>
  
  <pre><code>@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
  public void onViewDestroyed() {
      // This is not being called anymore
  }
  </code></pre>
  
  <p>But this stopped working after migrating from:</p>
  
  <pre><code>import android.arch.lifecycle.Lifecycle
  import android.arch.lifecycle.LifecycleObserver
  import android.arch.lifecycle.LifecycleOwner
  import android.arch.lifecycle.OnLifecycleEvent
  </code></pre>
  
  <p>to:</p>
  
  <pre><code>import androidx.lifecycle.Lifecycle
  import androidx.lifecycle.LifecycleObserver
  import androidx.lifecycle.LifecycleOwner
  import androidx.lifecycle.OnLifecycleEvent
  </code></pre>
  
  <p>Any ideas why this is not working anymore? </p>