Closed LandonPatmore closed 3 years ago
This is likely do to having the backup agent enabled for you application in your AndroidManifest.xml (https://github.com/google/dagger/issues/748#issuecomment-611663561), which replaces your actual application with android.app.Application
, as you can see from your error message:
Caused by: java.lang.IllegalStateException: Hilt service must be attached to an @AndroidEntryPoint Application. Found: class android.app.Application
Unfortunately, I think the only real fix currently is to set allowBackup="false"
in your AndroidManifest.
Funny enough, I already have allowBackup="false"
set in my manifest file.
Hmm, the allowBackup
case is the only time I've seen Android ignore the actual application class in the manifest. Just to check, have you specified the application name in the manifest?
Other than that, I'm not sure but it sounds like it's not specific to Hilt since the root of the issue is that Android is not using the application your specifying in your manifest.
The name is specified in the manifest. It was a project started from the Android Studio create a project page. It targets api 23
, but is compiled against 29
. Could that be any hint?
Sorry, I'm not really sure. I think the first thing to figure out is why Android is not using your application class, which shouldn't be related to Hilt. You might have luck asking on StackOverflow to see if anyone has run into similar issues.
I'm going to close this for now, but if you find more evidence that suggests this is related to Hilt we can reopen it.
@bcorso I pulled a bug dumb...I accidentally removed the android:name
from the AndroidManifest
file without realizing it... -_-
How can I throw this error? I have allowBackup="true" and app class with @HiltAndroidApp
Kotlin version: 1.3.72 Hilt (android, compiler, and plugin) version: 2.28.3-alpha
I'm trying to run a service in the background. I am using an application just so I can leverage Hilt for DI, but it will have no UI.
When I tried to run:
adb shell am startservice test.testflight/.TestFlightService
I got:
Starting service: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=test.testflight/.TestFlightService }
But my application crashed with:
My application class looks like:
My service class looks like: