Coder Social home page Coder Social logo

Comments (13)

pforhan avatar pforhan commented on August 27, 2024

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.

luisdelarosa avatar luisdelarosa commented on August 27, 2024

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.

luisdelarosa avatar luisdelarosa commented on August 27, 2024

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.

pforhan avatar pforhan commented on August 27, 2024

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.

cgruber avatar cgruber commented on August 27, 2024

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.

pforhan avatar pforhan commented on August 27, 2024

@cgruber FYI, in the 3rd comment, he shows an @Inject Store myStore; member in his activity class.

from dagger.

cgruber avatar cgruber commented on August 27, 2024

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.

pforhan avatar pforhan commented on August 27, 2024

@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 @Injected 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.

cgruber avatar cgruber commented on August 27, 2024

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 @Injected 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.

swankjesse avatar swankjesse commented on August 27, 2024

Found it & fixed it. #84

from dagger.

wombleabroad avatar wombleabroad commented on August 27, 2024

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.

swankjesse avatar swankjesse commented on August 27, 2024

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.

cgruber avatar cgruber commented on August 27, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.