简体   繁体   中英

Android Hilt Unresolved reference @Inject in Arctic Fox

After upgrade to Arctic Fox, @Inject suddenly missing... but still able to build the project.

Unresolved reference @Inject IDE hint

dependencies

AGP '7.1.0-alpha02'
hilt_version '2.37'
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip

I faced the same issue with @Inject. I tried invalidating cache and restart and everything but nothing worked.

The import path for @Inject was javax.inject.Inject.

When I tried to go to the "inject" package by hovering over "inject" from the import statement and CTRL + clicking it, it took me to some gradle cache folder and there was an interface named "Inject" inside it, so ideally the interface was there but android studio wasn't detecting it.

Then I went through some other folders inside the gradle cache with long random names and stuff, I found another package with the same structure (javax.inject) but it was empty. I deleted that empty package manually and the issue was fixed automatically. So I guess all this time android was considering the package with nothing inside it (that I deleted) and not the other one which had the Inject interface from cache. Deleting the empty package from cache fixed it for me.

I tried to recreate the issue to answer it with screenshots and stuff but I am not able to recreate it now. Sorry about that.

你能试试这个吗,这是一个类似的问题,对我有用https : //stackoverflow.com/a/70616657/9895306

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM