title: Hilt Injection not working with BroadcastReceiver
body: <p>Dependency injection inside <code>BroadcastReceiver</code> using Hilt isn't working. I try to invoke a <code>BroadcastReceiver</code> using an alarm from <code>MainActivity</code> and i am getting <code>UninitializedPropertyAccessException</code>. According to the documentation it should be as simple as adding the <code>@AndroidEntryPoint</code> annotation to the receiver but its not.</p>
  <p><em><strong>Sample Code:</strong></em></p>
  <p><strong>App.kt:</strong></p>
  <pre><code>@HiltAndroidApp
  class App: Application() {
      override fun onCreate() {
          super.onCreate()
          Log.d(App::class.simpleName, &quot;onCreate: Application&quot;)
      }
  }
  </code></pre>
  <p><strong>TestHiltInjection.kt:</strong></p>
  <pre><code>class TestHiltInjection @Inject constructor() {
  
      operator fun invoke() {
          Log.d(TestHiltInjection::class.java.simpleName, &quot;invoke called.&quot;)
      }
  }
  </code></pre>
  <p><strong>HiltBroadcastReceiver.kt:</strong></p>
  <pre><code>@AndroidEntryPoint
  class HiltBroadcastReceiver : BroadcastReceiver() {
  
      @Inject lateinit var testHiltInjection: TestHiltInjection
  
      override fun onReceive(context: Context?, intent: Intent?) {
          testHiltInjection()
      }
  }
  </code></pre>
  <p><strong>MainActivity.kt:</strong></p>
  <pre><code>@AndroidEntryPoint
  class MainActivity : AppCompatActivity() {
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          setContentView(R.layout.activity_main)
  
          val manager = getSystemService(Context.ALARM_SERVICE) as AlarmManager
  
          val pending = PendingIntent
              .getBroadcast(this, 0, Intent(this, HiltBroadcastReceiver::class.java), 0)
          manager.setInexactRepeating(
              AlarmManager.ELAPSED_REALTIME_WAKEUP,
              15000, 15000,
              pending
          )
      }
  }
  </code></pre>
  <p>Output Logcat:</p>
  <pre><code>kotlin.UninitializedPropertyAccessException: lateinit property testHiltInjection has not been initialized
  </code></pre>
  <p><strong>Update</strong></p>
  <p>Issue was already solved on 2.29.1 version, just use <code>@AndroidEntryPoint</code></p>