:app:hiltJavaCompile... fails with NoSuchElementException: No value present
See original GitHub issueAGP: 7.0.4 Hilt version: 2.40.5
I’m migrating a project from Dagger to Hilt. I started getting this error during build:
* What went wrong:
Execution failed for task ':app:hiltJavaCompileStagingPhyreWEPlayStoreDebug'.
> java.util.NoSuchElementException: No value present
The message is pretty vague and I have no idea where I messed up. The project is somewhat big, so it’s hard to check everything manually. I noticed that the Hilt_MyApplication is not being generated, however I’m not sure at what phase this should happen.
Having more details when this occurs would be helpful. Meanwhile any suggestions on how to debug it will be appreciated.
Issue Analytics
- State:
- Created 2 years ago
- Comments:9
Top Results From Across the Web
java.util.NoSuchElementException: No value present even ...
firstFirst returns an Optional , that you call get on, if that is an empty Optional - you will get that Exception.
Read more >java.util.NoSuchElementException: No value present" Data ...
1) Corruption of Data Domain weightage information is usually observed when import of OOTB content (infacmd mrs oie command execution) fails the ...
Read more >Flow Designer giving "java.util.NoSuchElementException
NoSuchElementException : No value present" error and aslo nt able to open executin details even if they are completed.
Read more >Jira Software Agile board throws Error No value present when ...
When attempting to access the Issue Detail View on an Agile board, the view does ... NoSuchElementException: No value present at java.util.
Read more >How to Fix the No Such Element Exception in Java - Rollbar
The NoSuchElementException in Java can be thrown by various accessor methods to indicate that the element being requested does not exist.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yep, that definitely explains it.
The retention determines where the annotation is stored/accessible (
SOURCE < BINARY < RUNTIME
). For Dagger, the retention needs to be at leastBINARY
. If you useSOURCE
, then anything that depends on your library will no longer see the annotation since the dependency is passed in as a class file. It’s the same reason I mentioned in https://github.com/google/dagger/issues/3133#issuecomment-1002790894, just a different cause.Okay, that makes sense. I guess it’s all clear now. Thanks for your assistance!