简体   繁体   English

Android Hilt Unresolved reference @Inject in Arctic Fox

[英]Android Hilt Unresolved reference @Inject in Arctic Fox

After upgrade to Arctic Fox, @Inject suddenly missing... but still able to build the project.升级到北极狐后,@Inject 突然不见了……但还是能建项目。

Unresolved reference @Inject IDE hint未解决的引用 @Inject IDE 提示

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.我在@Inject 上遇到了同样的问题。 I tried invalidating cache and restart and everything but nothing worked.我尝试使缓存无效并重新启动,但没有任何效果。

The import path for @Inject was javax.inject.Inject. @Inject 的导入路径是 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.当我尝试通过将鼠标悬停在导入语句中的“注入”上并按 CTRL + 单击它来进入“注入”包时,它会将我带到某个 gradle 缓存文件夹,其中有一个名为“注入”的界面,因此理想情况下界面在那里,但 android studio 没有检测到它。

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.然后我浏览了带有长随机名称和内容的 gradle 缓存中的其他一些文件夹,我发现了另一个具有相同结构的包(javax.inject),但它是空的。 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.所以我猜一直以来 android 都在考虑里面没有任何东西的包(我删除了),而不是另一个具有来自缓存的 Inject 接口的包。 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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