Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't generate DaggerAppComponent after update to dagger2.12 #942

Closed
rorschach opened this issue Nov 8, 2017 · 4 comments
Closed

Can't generate DaggerAppComponent after update to dagger2.12 #942

rorschach opened this issue Nov 8, 2017 · 4 comments

Comments

@rorschach
Copy link

rorschach commented Nov 8, 2017

After clean and recompile my Android project, it build failed and throws such error:
cannot find symbol class DaggerAppComponent.
Same issue occurs in 2.10/2.11/2.12, but it build success in dagger2.7.
This question has been bothering me for a long time, and I have no idea what the reason is.
I hope I can get some useful help or guidance here. Thanks for your reading.

@Singleton @Component(modules = { AppModule.class, ApiModule.class, RepositoryModule.class })
public interface AppComponent {
    void inject(BaseUserActivity activity);

    void inject(BaseUserService service);

    UserComponent.Builder userComponentBuilder();
}
@PerUser @Subcomponent(modules = UserModule.class) public interface UserComponent {

    @Subcomponent.Builder interface Builder {
        Builder sessionModule(UserModule userModule);
        UserComponent build();
    }

    LogoutManager logoutManager();

    void inject(SyncService service);

    TaskDetailComponent plus(TaskDetailComponent.TaskDetailModule module);
}

My dependency:

daggerVersion = "2.12"
epoxyVersion = '2.5.1'
butterKnifeVersion = '8.8.1'
autoValueVersion = '1.5'
autoValueGsonVersion = '0.6.0'
autoValueParcelVersion = '0.2.5'

dagger                 : "com.google.dagger:dagger:${daggerVersion}",
daggercompiler         : "com.google.dagger:dagger-compiler:${daggerVersion}",
butterknife            : "com.jakewharton:butterknife:${butterKnifeVersion}",
butterknifecompiler    : "com.jakewharton:butterknife-compiler:${butterKnifeVersion}",
gson                   : "com.google.code.gson:gson:${gsonVersion}",
auto_value_annotation  : "com.jakewharton.auto.value:auto-value-annotations:${autoValueVersion}",
auto_value             : "com.google.auto.value:auto-value:${autoValueVersion}",
auto_value_gson        : "com.ryanharter.auto.value:auto-value-gson:${autoValueGsonVersion}",
auto_value_parcel      : "com.ryanharter.auto.value:auto-value-parcel:${autoValueParcelVersion}",
epoxy                  : "com.airbnb.android:epoxy:${epoxyVersion}",
epoxyprocessor         : "com.airbnb.android:epoxy-processor:${epoxyVersion}",
@ronshapiro
Copy link

Can you create a github repo which exhibits the issue? This is essentially the same thing you posted inj #938.

@rorschach
Copy link
Author

I have 2 custom scope @PerUser and @PerActivity, and there were some code like below:

@PerActivity @Subcomponent(modules = HomeMemberModule.class)
public interface HomeActivityComponent {

    HomeActivity inject(HomeActivity activity);
    AppsContainerActivity inject(AppsContainerActivity activity);
    NavigationFragment inject(NavigationFragment fragment);

    @Module class HomeMemberModule extends MemberModule<AppCompatActivity> {
        public HomeMemberModule(AppCompatActivity activity) {
            super(activity);
        }

        @Provides PagerAdapter providesPagerAdapter() {
            return new PagerAdapter(mObject2Inject.getSupportFragmentManager());
        }
    }

    OwnTaskComponent plus(OwnTaskComponent.Module module);
    ParticipantsTaskComponent plus(ParticipantsTaskComponent.Module module);
    TaskTeamComponent plus(TaskTeamComponent.Module module);
    CrmHomeFragComponent plus(CrmHomeFragComponent.CrmHomeFragModule module);
    ContactsComponent plus(ContactsComponent.ContactsModule module);
    AppsComponent plus(AppsComponent.AppsFragmentModule module);
    UserCenterComponent plus(UserCenterComponent.UserCenterModule module);
    OwnActivitiesComponent plus(OwnActivitiesComponent.OwnActivitiesModule module);
    OwnClientsComponent plus(OwnClientsComponent.OwnClientsPresenterModule module);
    TeamComponent plus(TeamComponent.TeamPresenterModule module);
}
@PerActivity @Subcomponent(modules = Module.class) public interface OwnTaskComponent {

    void inject(OwnTaskFragment fragment);

    @dagger.Module class Module extends MemberModule<OwnTaskFragment> {
        public Module(OwnTaskFragment object2Inject) {
            super(object2Inject);
        }

        @PerActivity @Provides OwnTaskContract.View provideView() {
            return mObject2Inject;
        }
    }
}

And I inject AppComponent in BaseUserActivity:

public abstract class BaseUserActivity extends BaseActivity {
    @Inject protected UserManager mUserManager;

    @Override protected void initInjection() {
        App.get(this).getAppComponent().inject(this);
        setupUserComponent();
    }

    private void setupUserComponent() {
        isUserSessionStarted = mUserManager.isUserSessionStartedOrStartSessionIfPossible();
        UserComponent userComponent = mUserManager.getUserComponent();
        onUserComponentSetup(userComponent);
        if (!isUserSessionStarted) {
            finish();
        }
    }

    protected abstract void onUserComponentSetup(UserComponent component);
}

Could the problems arise between them?

@rorschach
Copy link
Author

@ronshapiro I find I had post wrong info, so I create new issue.
The problem is that the project has commercial USES, so I can't upload the code, and I'm sorry about that

@ronshapiro
Copy link

I recommend asking on stack overflow. It's better for questions.

If you want to try and use git bisect to find which commit broke you, that could also help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants