Comments (13)
Are you instantiating one of these directly, or are you subclassing? And this almost looks like you are using Dagger to construct an activity, which flies in the face of Android...
from dagger.
Subclassing.
Sorry - I cut off the error message, so perhaps that will give a better clue. Here's the full message:
Caused by: java.lang.IllegalStateException: Errors creating object graph:
No injectable members on com.actionbarsherlock.app.SherlockFragmentActivity. Do you want to add an injectable constructor? required by members/com.luisdelarosa.MyApplication.MyActivity
MyActivity looks like:
public class MyActivity extends SherlockFragmentActivity {
@Inject MyStore store;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
((MyApplication) getApplication()).inject(this);
// more work here
}
}
Also, MyActivity is declared as an entryPoint.
from dagger.
I just pulled and merged the latest upstream master and got a different exception:
Caused by: java.lang.IllegalStateException: Errors creating object graph:
No available @Inject handlers could be found for key members/com.actionbarsherlock.app.SherlockFragmentActivity in class com.actionbarsherlock.app.SherlockFragmentActivity required by members/com.luisdelarosa.MyActivity
at dagger.internal.ThrowingErrorHandler.handleErrors(ThrowingErrorHandler.java:34)
at dagger.internal.Linker.linkRequested(Linker.java:123)
at dagger.ObjectGraph.getEntryPointBinding(ObjectGraph.java:214)
at dagger.ObjectGraph.inject(ObjectGraph.java:196)
at com.luisdelarosa.MyApplication.inject(MyApplication.java:38)
at com.luisdelarosa.MyActivity.onCreate(MyActivity.java:26)
at android.app.Activity.performCreate(Activity.java:5008)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
Then I added an explicit constructor in SherlockFragmentActivity.
@Inject
public SherlockFragmentActivity() {
}
This explicit constructor fixes these errors. I'd like to understand better why this would be required, though. I assume this isn't normal ABS/Dagger integration.
Thanks.
from dagger.
Generally, something must have an @Inject in it somewhere to function. However, it does not need that for super classes.
What you have looks pretty good. @swankjesse, any thoughts?
And just a sanity check, you're not @injecting an activity anywhere, are you?
from dagger.
If you got the no at inject provider could be found that probably means you
didn't have anything @Inject marked so the code gen has no way to know to
create an adapter for it, and the reflection based handler has nothing
marked to look up.
You need to add an @Inject constructor or field(s).
Regards,
Christian
Sent from my iPhone.
On Oct 25, 2012, at 18:32, Patrick Forhan [email protected] wrote:
Generally, something must have an @Inject https://github.com/Inject in
it somewhere to function. However, it does not need that for super classes.
What you have ooks pretty good. @swankjesse https://github.com/swankjesse,
any thoughts?
And just a sanity check, you're not @injecting an activity anywhere, are
you?
—
Reply to this email directly or view it on
GitHubhttps://github.com//issues/74#issuecomment-9796832.
from dagger.
@cgruber FYI, in the 3rd comment, he shows an @Inject Store myStore; member in his activity class.
from dagger.
Sorry. Missed it. Reading on my phone.
Upon further thought, I don't think we process annotations on superclasses
currently. I recall a getDeclaredConstructors() call (vaguely from
memory). We need to decide how we want to handle @Inject on parent types
if there are no local members that are annotated.
Regards,
Christian
Sent from my iPhone.
On Oct 25, 2012, at 18:51, Patrick Forhan [email protected] wrote:
@cgruber https://github.com/cgruber FYI, in the 3rd comment, he shows an
@Inject https://github.com/Inject Store myStore; member in his activity
class.
—
Reply to this email directly or view it on
GitHubhttps://github.com//issues/74#issuecomment-9797359.
from dagger.
@cgruber, did you ever look at this again? The way I understand it, this wasn't about annotations on super classes, it was a confusing message Dagger was giving out about a library superclass -- @Inject
was in the subclass, but Dagger was complaining that the super class didn't have any @Inject
ed members.
We do this with no issue (even the extending of SherlockFragmentActivity), but I don't know if there is some magic combination that @luisdelarosa is hitting upon.
from dagger.
On 29 Oct 2012, at 11:16, Patrick Forhan wrote:
@cgruber, did you ever look at this again? The way I understand it,
this wasn't about annotations on super classes, it was a confusing
message Dagger was giving out about a library superclass --@Inject
was in the subclass, but Dagger was complaining that the super class
didn't have any@Inject
ed members.We do this with no issue (even the extending of
SherlockFragmentActivity), but I don't know if there is some magic
combination that @luisdelarosa is hitting upon.
Hadn't gotten to it. I'll dig into it today and/or tomorrow.
c.
from dagger.
Found it & fixed it. #84
from dagger.
Not sure whether or not to create a new issue here, but this fix works fine when using the reflection strategy. Using 0.9 artifcacts, if I switch to the code generation strategy (by adding the dagger-compiler plugin dependency) I get the following error at runtime:
java.lang.IllegalStateException: Errors creating object graph:
No injectable members on com.actionbarsherlock.app.SherlockFragmentActivity. Do you want to add an injectable constructor? required by class com.foo.MyActivity
at dagger.internal.ThrowingErrorHandler.handleErrors(ThrowingErrorHandler.java:34)
at dagger.internal.Linker.linkRequested(Linker.java:136)
at dagger.ObjectGraph.getEntryPointBinding(ObjectGraph.java:264)
at dagger.ObjectGraph.inject(ObjectGraph.java:238)
at com.foo.MyActivity.onCreate(MyActivity.java:n)
I noticed that in MyActivity$InjectAdapter, the supertype instance field is set like this in the attach method:
supertype = (dagger.internal.Binding<com.actionbarsherlock.app.SherlockFragmentActivity>) linker.requestBinding("members/com.actionbarsherlock.app.SherlockFragmentActivity", com.foo.MyActivity.class);
The two argument Linker.requestBinding method calls the three argument Linker.requestBinding method with mustBeInjectable = true. Could this be the source of the error?
from dagger.
Really fixed this with #102.
We didn't catch this in our own apps 'cause we accidentally disabled dagger-compiler when that code was split from the main module. We're running it now. That explains why I didn't see it.
Thanks!
from dagger.
On 11 Nov 2012, at 18:31, Jesse Wilson wrote:
We didn't catch this in our own apps 'cause we accidentally disabled
dagger-compiler when that code was split from the main module. We're
running it now. That explains why I didn't see it.
Good test on #102, btw, Jesse.
from dagger.
Related Issues (20)
- java.lang.NoClassDefFoundError: dagger.internal.Preconditions HOT 2
- java.lang.NoClassDefFoundError: dagger.internal.Preconditions HOT 1
- android.app.Application does not implement dagger.android.HasActivityInjector HOT 3
- --
- Android Context HOT 1
- Subcomponent inside subcomponent HOT 1
- Error when a component is trying to include bindings with different scopes could be more informative HOT 1
- Constructor injection cannot find symbol method inject members dagger2 2.14 HOT 1
- how can i run the example of CoffeeApp.java HOT 1
- Why do Singletons need an empty default constructor? HOT 2
- dagger-compiler
- dagger.android.DispatchingAndroidInjector cannot be provided without an @Provides HOT 1
- 每次修改完java代码都需要clean项目 才能运行, HOT 1
- did u consider this kind of case: ChildFragment needs to reuse ParentFragment's object instead of creating a new one。hilt may not support this kind of case
- duplicate Nullable HOT 2
- cannot generate
- Support extending base builder classes HOT 2
- The Hilt Android Gradle plugin is applied but no com.google.dagger:hilt-android dependency was found. HOT 1
- Issue with enableAggregatingTask flag / AGP 7.0 / oss-licenses HOT 1
- after add hilt { enableAggregatingTask = true } dependencies tasks faild
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.