title: Inject context with Hilt: this field leaks a context object
body: <p>I'm using Hilt to inject context and other dependencies into my HomeViewModel class; Everything is working properly but I'm getting this warning.
  How can I prevent from leakings?</p>
  <p>This is my HomeFragment (where I inject and use the HomeViewModel class):</p>
  <pre><code>@AndroidEntryPoint
  class HomeFragment : Fragment() {
  
  private val viewModel: HomeViewModel by viewModels()
  
  ....
  
  }
  </code></pre>
  <p>This is the warning:</p>
  <p><a href="https://i.stack.imgur.com/okp8K.png" rel="noreferrer"><img src="https://i.stack.imgur.com/okp8K.png" alt="Hilt injection viewModel" /></a></p>
  <pre><code>class HomeViewModel @ViewModelInject constructor(
      @ApplicationContext val context: Context,
      private val locationAPI: LocationAPI,
      private val imagesAPI: ImagesAPI
  ) :
      ViewModel() {
  ...
  }
  </code></pre>
  <p>I'm using:</p>
  <pre><code>//Hilt DI
  implementation &quot;com.google.dagger:hilt-android:2.30.1-alpha&quot;
  kapt &quot;com.google.dagger:hilt-android-compiler:2.30.1-alpha&quot;
  implementation &quot;androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha02&quot;
  kapt &quot;androidx.hilt:hilt-compiler:1.0.0-alpha02&quot;
  </code></pre>
  <p>Thanks!</p>
  <p><strong>-- Edited, as suggested, after the first given answer:</strong></p>
  <p>The Home Fragment now is:</p>
  <p><a href="https://i.stack.imgur.com/lxFkT.png" rel="noreferrer"><img src="https://i.stack.imgur.com/lxFkT.png" alt="enter image description here" /></a></p>
  <pre><code>@HiltViewModel
  class DetailsViewModel @Inject constructor(
      @ApplicationContext val context: Context,
      private val locationDetailsAPI: LocationAPI) :
      ViewModel() {
  ...
  
  }
  </code></pre>
  <p>Dependencies updated to:</p>
  <pre><code>//Hilt DI
  implementation &quot;com.google.dagger:hilt-android:2.31-alpha&quot;
  kapt &quot;com.google.dagger:hilt-android-compiler:2.30.1-alpha&quot;
  implementation &quot;androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha03&quot;
  kapt &quot;androidx.hilt:hilt-compiler:1.0.0-alpha03&quot;
  </code></pre>
  <p>And I'm still getting this leaking error.</p>
  <p>Any ideias?</p>