title: Activity cannot be cast to LifecycleOwner
body: <p>My <code>MainActivity</code> extends <code>AppCompatActivity</code></p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  private WebsiteViewModel websiteViewModel;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
  
        setContentView(R.layout.activity_main);
  
          RecyclerView recyclerView = findViewById(R.id.recycler_view);
          recyclerView.setLayoutManager(new LinearLayoutManager(this));
          recyclerView.setHasFixedSize(true);
  
          final WebsiteAdapter adapter = new WebsiteAdapter();
  
  
          this.websiteViewModel = ViewModelProviders.of(this).get(WebsiteViewModel.class);
  
          this.websiteViewModel.getAllWebsites().observe(this, new Observer&lt;List&lt;Website&gt;&gt;() {
              @Override
              public void onChanged(@Nullable List&lt;Website&gt; websites) {
                  adapter.setWebsites(websites);
              }
          });
          recyclerView.setAdapter(adapter);
      }
  }
  </code></pre>
  
  <p>The error I am facing is "error: incompatible types: MainActivity cannot be converted to LifecycleOwner."</p>
  
  <p>The <code>WebsiteViewModel</code> is </p>
  
  <pre><code>    public class WebsiteViewModel extends AndroidViewModel {
      private WebsiteRepository repository;
      private LiveData&lt;List&lt;Website&gt;&gt; allWebsites;
  
      public WebsiteViewModel(@NonNull Application application) {
          super(application);
          repository = new WebsiteRepository(application);
          allWebsites = repository.getAllWebsites();
      }
  
      public void insert(Website website) {
          repository.insert(website);
      }
  
      public void update(Website website) {
          repository.update(website);
      }
  
      public void delete(Website website) {
          repository.delete(website);
      }
  
      public void deleteAllWebsites() {
          repository.deleteAllWebsites();
      }
  
      public LiveData&lt;List&lt;Website&gt;&gt; getAllWebsites() {
          return allWebsites;
      }
  }
  </code></pre>
  
  <p>In my other project, I am using a <code>Fragment</code> rather than an <code>Activity</code> to cast to a lifecycle owner, and that project runs without this error. However I am copying from <a href="https://codinginflow.com/tutorials/android/room-viewmodel-livedata-recyclerview-mvvm/part-6-recyclerview-adapter" rel="noreferrer">https://codinginflow.com/tutorials/android/room-viewmodel-livedata-recyclerview-mvvm/part-6-recyclerview-adapter</a>, but I dont know why I am having this issue. I using androidx</p>
  
  <p>If I add implements LifecycleOwner in MainActivity then I get the error " java.lang.NoSuchMethodError: No super method getLifecycle()Landroidx/lifecycle/Lifecycle; in class Landroidx/core/app/ComponentActivity; or its super classes (declaration of 'androidx.core.app.ComponentActivity' appears in /data/app/com.example.project-2/split_lib_dependencies_apk.apk)"</p>