Comments (14)
Are there any compilation errors higher up? I think this might happen if you are trying to inject a type that does not exist (i.e., a missing class), but I'm also not exactly sure.
The code problem is here where the dependency request's type is attempted to be converted to an element. This ends up returning null
, presumably as documented: "Returns null
if the type is not one with a corresponding element." MoreElements
then attempts to invoke a method on that null
element which causes the NPE.
from dagger.
Debugging the annotation processor, it seems that I have this missing from my component:
@Named(FrameworkModule.ADMOB_TEST_DEVICES)
String[] admobTestDevices();
Adding that made the build progress and now I'm getting this:
Caused by: java.lang.IllegalArgumentException: java.lang.String[] does not represent a declared type
at com.google.auto.common.MoreTypes$CastingTypeVisitor.defaultAction(MoreTypes.java:581)
at com.google.auto.common.MoreTypes$CastingTypeVisitor.defaultAction(MoreTypes.java:579)
at com.sun.tools.javac.code.Type$ArrayType.accept(Type.java:1117)
at com.google.auto.common.MoreTypes.asDeclared(MoreTypes.java:424)
at dagger.internal.codegen.MethodSignatureFormatter.nameOfType(MethodSignatureFormatter.java:89)
at dagger.internal.codegen.MethodSignatureFormatter.format(MethodSignatureFormatter.java:60)
at dagger.internal.codegen.BindingGraphValidator.validateComponentScope(BindingGraphValidator.java:118)
at dagger.internal.codegen.BindingGraphValidator.validate(BindingGraphValidator.java:54)
at dagger.internal.codegen.ComponentProcessingStep.process(ComponentProcessingStep.java:71)
at dagger.internal.codegen.ComponentProcessor.process(ComponentProcessor.java:146)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:794)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:705)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91)
at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1035)
at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1176)
at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856)
at com.sun.tools.javac.main.Main.compile(Main.java:523)
from dagger.
It looks like the code generation for the component doesn't know how to call the method when it returns an array. I suppose MethodSignatureFormatter.nameOfType
should try to call MoreTypes.asArray
as there are types that are not primitives nor declared.
from dagger.
Cool. Keep 'em coming. Proper error messages will be a big focus before a
release can happen.
On Nov 18, 2014 12:59 AM, "Serandel" [email protected] wrote:
It looks like the code generation for the component doesn't know how to
call the method when it returns an array. I suppose
MethodSignatureFormatter.nameOfType should try to call MoreTypes.asArray
as there are types that are not primitives nor declared.—
Reply to this email directly or view it on GitHub
#75 (comment).
from dagger.
Yeah - that's definitely a bug in how we generate. :(
On Tue Nov 18 2014 at 10:11:02 AM Jake Wharton [email protected]
wrote:
Cool. Keep 'em coming. Proper error messages will be a big focus before a
release can happen.
On Nov 18, 2014 12:59 AM, "Serandel" [email protected] wrote:It looks like the code generation for the component doesn't know how to
call the method when it returns an array. I suppose
MethodSignatureFormatter.nameOfType should try to call MoreTypes.asArray
as there are types that are not primitives nor declared.—
Reply to this email directly or view it on GitHub
#75 (comment).—
Reply to this email directly or view it on GitHub
#75 (comment).
from dagger.
Ok - can this be reproduced on the current snapshots? We've done a lot of re-writing in this code-path, so I'm going to close this for now, but if you can reproduce this with current snapshots, please re-open, ideally with a repro case.
from dagger.
I'm trying to migrate my project from dagger to dagger-2.0 ('com.google.dagger:dagger-compiler:2.0' from jcenter), but build failed.
Caused by: java.lang.IllegalArgumentException: com.github.baoti.git.GitSource[] does not represent a d eclared type at dagger.shaded.auto.common.MoreTypes$CastingTypeVisitor.defaultAction(MoreTypes.java:770) at dagger.shaded.auto.common.MoreTypes$CastingTypeVisitor.defaultAction(MoreTypes.java:768) at com.sun.tools.javac.code.Type$ArrayType.accept(Type.java:1117) at dagger.shaded.auto.common.MoreTypes.asDeclared(MoreTypes.java:524) at dagger.internal.codegen.MethodSignatureFormatter.nameOfType(MethodSignatureFormatter.java:1 09) at dagger.internal.codegen.MethodSignatureFormatter.format(MethodSignatureFormatter.java:77) at dagger.internal.codegen.MethodSignatureFormatter.format(MethodSignatureFormatter.java:49) at dagger.internal.codegen.BindingGraphValidator.validateComponentScope(BindingGraphValidator. java:541) at dagger.internal.codegen.BindingGraphValidator.validate(BindingGraphValidator.java:118) at dagger.internal.codegen.BindingGraphValidator.validate(BindingGraphValidator.java:111) at dagger.internal.codegen.ComponentProcessingStep.process(ComponentProcessingStep.java:77) at dagger.shaded.auto.common.BasicAnnotationProcessor.process(BasicAnnotationProcessor.java:22 8) at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvi ronment.java:794) at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessi ngEnvironment.java:705) at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnviro nment.java:91) at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironm ent.java:1035) at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvir onment.java:1176) at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170) at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856) at com.sun.tools.javac.main.Main.compile(Main.java:523) ... 66 more
from dagger.
@baoti Looking at the referenced code from the stacktrace (BindingGraphValidator.java:541 and MethodSignatureFormatter.java:77) it seems like you have a method in either your component or module that returns an array of GitSource
and incorrectly has dependencies of different scopes (or some other issue related to scopes, see the comment in BindingGraphValidator).
Indeed your error is shadowed by one thrown when trying to build the error message, because of the array type, which is the same error as in the 3rd comment above
@cgruber This does not seem to have been fixed:
Since 2.0 there's a new special case for
void
but it'll still fail for arrays I believe.from dagger.
@tbroyer Thanks for your nice explaining!
from dagger.
But I doesn't understand why is dagger.shaded.auto.common.MoreTypes
in my stacktrace, but com.google.auto.common.MoreTypes
in serandel's stacktrace.
I didn't found the dagger.shaded.auto.common.MoreTypes
class in this repository.
from dagger.
@baoti It's com.google.auto.common.MoreTypes
that's been renamed (shaded, by the maven-shade-plugin) at build-time to avoid runtime conflicts.
from dagger.
👍
from dagger.
I'll bump this up. We're hoping for a 2.0.1 nearly immediately, but this seems worth fixing and getting in to that.
from dagger.
I just had this error message with Dagger 2.0.1:
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> java.lang.IllegalArgumentException: com.example.Project[] does not represent a declared type
The problem was that I didn't write a Project[] getProjects();
in the component that my component depends on.
If the Type is Project
instead of Project[]
the error is correct:
Error:(31, 10) error: com.example.Project cannot be provided without an @Inject constructor or from an @Provides- or @Produces-annotated method.
com.example.MainActivity.projects
[injected field of type: com.example.Project projects]
from dagger.
Related Issues (20)
- Subcomponent MembersInjector error in 2.51 HOT 1
- Does Hilt always execute app module during instrumented test? HOT 3
- [KSP] Dagger-KSP does not see typealiased dagger annotations HOT 3
- Cannot invoke getAnnotationValue because "annotation" is null HOT 14
- Creator-less subcomponents are not visible to modules HOT 1
- Suggestion to add isInit() api to dagger.Lazy HOT 1
- [Error] : java.lang.ClassNotFoundException: Didn't find class "com.myproject.MainApplication" on path: DexPathList HOT 1
- K2 KAPT (aka KAPT4) doesn't like inline/reified. HOT 3
- [KSP2] ClassCastException: class KSClassDeclarationEnumEntryImpl cannot be cast to class XEnumEntry HOT 2
- Hilt: Injection not working in BroadcastReceiver HOT 3
- Assisted injection appears to not work correctly in some cases HOT 3
- [Dagger/MissingBinding] com.xxx.onboarding.presentation.otp.LoginViewModel cannot be provided without an @Inject constructor or an @Provides-annotated method. public abstract static class SingletonC implements SemaaiApplication_GeneratedInjector HOT 1
- Hilt Class Generation Fails After Upgrading to AGP 8.5.1 from 8.0.1 HOT 6
- Issue with Dagger Hilt Upgrade from 2.48 to 2.49 - Unable to Load Class JavacBasicAnnotationProcessor HOT 1
- Way to replace a dependency created using Constructor Injection for all tests using Hilt. HOT 4
- After updating from 2.51.1 to 2.52, my GWT application does not compile HOT 1
- NPE On Lazy Dagger
- [KSP] Component processing is not deferred if there are unresolved symbols in the current round HOT 2
- [KAPT] - Issue build type release AGP 8.4.0 - 8.5.2 Kotlin 1.9.24 and Dagger 2.52
- SomeClass$LazyClassKeyProviders.class generated by Dagger/Hilt is not deterministic
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dagger.