I've been adding all of the components in the di folder of the githubbrowsersample (java) and seemed to be causing no fuss until it came to creating the AppInjector as it doesn't want to generate DaggerAppComponent, I know in the sample its showing in the generatedJava folder and not for me, so that is why it is not resolvable but i'm not sure how I can resolve it.
I have tried the usual suspects, invalid cache, trying different alternatives in gradle, seeing what android.enableSeparateAnnotationProcessing=true did, adding -Pandroid.incrementalJavaCompile = false, found many posts from many others facing similar issues but I simply cannot figure out why my code is not playing ball.
Build.gradle (Module: app):
implementation "com.google.dagger:dagger:$rootProject.dagger"
annotationProcessor "com.google.dagger:dagger-compiler:$rootProject.dagger"
implementation "com.google.dagger:dagger-android:$rootProject.dagger"
implementation "com.google.dagger:dagger-android-support:$rootProject.dagger" // if you use the support libraries
annotationProcessor "com.google.dagger:dagger-android-processor:$rootProject.dagger"
My build errors, some of which seem to only occur when the di is in situ:
Gradle may disable incremental compilation as the following annotation processors are not incremental: dagger-compiler-2.17.jar (com.google.dagger:dagger-compiler:2.17), dagger-android-processor-2.17.jar (com.google.dagger:dagger-android-processor:2.17), room-compiler-2.0.0.jar (androidx.room:room-compiler:2.0.0), lifecycle-compiler-2.0.0.jar (androidx.lifecycle:lifecycle-compiler:2.0.0), databinding-compiler-3.4.1.jar (androidx.databinding:databinding-compiler:3.4.1).
Consider setting the experimental feature flag android.enableSeparateAnnotationProcessing=true in the gradle.properties file to run annotation processing in a separate task and make compilation incremental.
D:\AndroidStudioProjects\smhApp\binding\FragmentDataBindingComponent.java:5: error: cannot find symbol
public class FragmentDataBindingComponent implements androidx.databinding.DataBindingComponent {
^
symbol: class DataBindingComponent
location: package androidx.databinding
D:\AndroidStudioProjects\smhApp\ui\u\category\CategoryFragment.java:32: error: cannot find symbol
androidx.databinding.DataBindingComponent dataBindingComponent = new FragmentDataBindingComponent(this);
^
symbol: class DataBindingComponent
location: package androidx.databinding
D:\AndroidStudioProjects\smhApp\ui\u\common\CategoryListAdapter.java:39: error: cannot find symbol
public CategoryListAdapter(DataBindingComponent dataBindingComponent) {
^
symbol: class DataBindingComponent
location: class CategoryListAdapter
D:\AndroidStudioProjects\smhApp\di\AppModule.java:35: error: com.smhapp.di.ViewModelModule has errors
@Module(includes = ViewModelModule.class)
^
D:\AndroidStudioProjects\smhApp\di\ViewModelModule.java:20: error: @Binds methods' parameter type must be assignable to the return type
abstract ViewModelProvider.Factory bindViewModelFactory(CrosscareService factory);
^
D:\AndroidStudioProjects\smhApp\di\AppComponent.java:29: error: com.smhapp.di.AppModule has errors
@Component(modules = {
^
D:\AndroidStudioProjects\smhApp\ui\u\category\CategoryFragment.java:25: error: [ComponentProcessor:MiscError] dagger.internal.codegen.ComponentProcessor was unable to process this class because not all of its dependencies could be resolved. Check for compilation errors or a circular dependency with generated code.
public class CategoryFragment extends Fragment implements Injectable {
^
7 errors
> Task :app:compileDebugJavaWithJavac FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
Must have spent at least an hour looking through to find solutions.
thanks for your time.
Was poor copying and pasting on my behalf. I figured it out by slowly reintroducing everything in AppModule.java and then noted that I had put the equivent of GithubService rather than GithubViewFactory in ViewModelModule.
Now compiles fine.