title: java.lang.IllegalStateException :ViewTreeLifecycleOwner not found from DecorView@5ab7e30[MainActivity]
body: <p>i followed <a href="https://developer.android.com/jetpack/compose/interop#compose-in-views" rel="noreferrer">this</a> documentation for  including a <strong>ComposeView</strong> directly inside a fragment <strong>without xml layout inflating</strong> , but it giving <strong>java.lang.IllegalStateException</strong>.</p>
  <p>please help me to fix this issue.</p>
  <p>Android Studio: 2020.3.1 canary 14</p>
  <p>compose_version :'1.0.0-beta01'</p>
  <p>this is Fragment's code:</p>
  <pre><code>class RecipeListFragment : Fragment() {
  
  private lateinit var viewModel: RecipeListViewModel
  
  override fun onCreateView(
      inflater: LayoutInflater, container: ViewGroup?,
      savedInstanceState: Bundle?
  ): View {
      return ComposeView(requireContext()).apply {
          setContent {
              Column(
                  modifier = Modifier
                      .padding(16.dp)
              ) {
                  Text(
                      text = &quot;Recipe List&quot;,
                      style = MaterialTheme.typography.h3
                  )
              }
          }
      }
  
  }
  
  override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
      super.onViewCreated(view, savedInstanceState)
      viewModel = ViewModelProvider(this).get(RecipeListViewModel::class.java)
  }
  </code></pre>
  <p>}</p>
  <p>this is run time error:</p>
  <pre><code>E/AndroidRuntime: FATAL EXCEPTION: main
  Process: com.example.mvvmrecepiapp, PID: 18722
  java.lang.IllegalStateException: ViewTreeLifecycleOwner not found from DecorView@5ab7e30[MainActivity]
      at androidx.compose.ui.platform.WindowRecomposer_androidKt.createLifecycleAwareViewTreeRecomposer(WindowRecomposer.android.kt:214)
      at androidx.compose.ui.platform.WindowRecomposer_androidKt.access$createLifecycleAwareViewTreeRecomposer(WindowRecomposer.android.kt:1)
      at androidx.compose.ui.platform.WindowRecomposerFactory$Companion$LifecycleAware$1.createRecomposer(WindowRecomposer.android.kt:97)
      at androidx.compose.ui.platform.WindowRecomposerPolicy.createAndInstallWindowRecomposer$ui_release(WindowRecomposer.android.kt:152)
      at androidx.compose.ui.platform.WindowRecomposer_androidKt.getWindowRecomposer(WindowRecomposer.android.kt:200)
      at androidx.compose.ui.platform.AbstractComposeView.ensureCompositionCreated(ComposeView.android.kt:200)
      at androidx.compose.ui.platform.AbstractComposeView.onAttachedToWindow(ComposeView.android.kt:235)
      at android.view.View.dispatchAttachedToWindow(View.java:19553)
      at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3430)
      at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3437)
      at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3437)
      at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3437)
      at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3437)
      at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3437)
      at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3437)
      at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3437)
      at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3437)
      at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2028)
      at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1721)
      at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7598)
      at android.view.Choreographer$CallbackRecord.run(Choreographer.java:966)
      at android.view.Choreographer.doCallbacks(Choreographer.java:790)
      at android.view.Choreographer.doFrame(Choreographer.java:725)
      at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:951)
      at android.os.Handler.handleCallback(Handler.java:883)
      at android.os.Handler.dispatchMessage(Handler.java:100)
      at android.os.Looper.loop(Looper.java:214)
      at android.app.ActivityThread.main(ActivityThread.java:7356)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
  </code></pre>
  <p><strong>UPDATE:</strong></p>
  <p>here is my build.gradle(:app)</p>
  <pre><code>plugins {
      id 'com.android.application'
      id 'kotlin-android'
  }
  
  android {
      compileSdk 30
      buildToolsVersion &quot;30.0.3&quot;
  
      defaultConfig {
          applicationId &quot;com.example.mvvmrecepiapp&quot;
          minSdk 21
          targetSdk 30
          versionCode 1
          versionName &quot;1.0&quot;
  
          testInstrumentationRunner &quot;androidx.test.runner.AndroidJUnitRunner&quot;
          vectorDrawables {
              useSupportLibrary true
          }
      }
  
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
          }
      }
      compileOptions {
          sourceCompatibility JavaVersion.VERSION_1_8
          targetCompatibility JavaVersion.VERSION_1_8
      }
      kotlinOptions {
          jvmTarget = '1.8'
          useIR = true
      }
      buildFeatures {
          compose true
      }
      composeOptions {
          kotlinCompilerExtensionVersion compose_version
          kotlinCompilerVersion '1.4.32'
      }
  }
  
  dependencies {
      implementation 'androidx.appcompat:appcompat:1.2.0'
      implementation 'androidx.core:core-ktx:1.3.2'
      implementation 'androidx.legacy:legacy-support-v4:1.0.0'
  
      implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
      implementation 'com.google.android.material:material:1.3.0'
  
  //    compose_version = &quot;1.0.0-beta01&quot; variable in project level build.gradle
      implementation &quot;androidx.compose.ui:ui:$compose_version&quot;
      implementation &quot;androidx.compose.material:material:$compose_version&quot;
      implementation &quot;androidx.compose.ui:ui-tooling:$compose_version&quot;
  
  
      implementation 'androidx.activity:activity-compose:1.3.0-alpha06'
  
      implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1'
      implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1'
      implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
  
      def fragment_version = &quot;1.3.2&quot;
      implementation &quot;androidx.fragment:fragment-ktx:$fragment_version&quot;
  
      def nav_version = &quot;2.3.5&quot;
      implementation &quot;androidx.navigation:navigation-fragment-ktx:$nav_version&quot;
      implementation &quot;androidx.navigation:navigation-ui-ktx:$nav_version&quot;
  
  
       testImplementation 'junit:junit:4.13.2'
       androidTestImplementation 'androidx.test.ext:junit:1.1.2'
       androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
       androidTestImplementation &quot;androidx.compose.ui:ui-test-junit4:1.0.0-beta04&quot;
  
  }
  </code></pre>