This is my first time with Dagger and I am learning I via a project. I did create a component and a module and ensured I had right dependencies in the grade file. However when I build my project, the auto-generated file is nowhere visible.

Below is the component and module class:

```
package com.mario.photoapp.dependency;

import com.mario.photoapp.photoalbum.ImageActivity;
import com.mario.photoapp.services.NetworkModule;

import javax.inject.Singleton;
import dagger.Component;

@Singleton
@Component(modules = {NetworkModule.class,})
public interface Dependency {
    void inject(ImageActivity imageActivity);
}

```

Module class:

```
package com.mario.photoapp.services;

import com.mario.photoapp.BuildConfig;

import java.io.File;
import java.io.IOException;

import javax.inject.Singleton;

import dagger.Module;
import dagger.Provides;
import okhttp3.Cache;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
import retrofit2.converter.scalars.ScalarsConverterFactory;

@Module
public class NetworkModule {
    File cacheFile;

    public NetworkModule(File cacheFile) {
        this.cacheFile = cacheFile;
    }

    @Provides
    @Singleton
    Retrofit provideCall() {
        Cache cache = null;
        try {
            cache = new Cache(cacheFile, 10 * 1024 * 1024);
        } catch (Exception e) {
            e.printStackTrace();
        }

        OkHttpClient okHttpClient = new OkHttpClient.Builder()
                .addInterceptor(new Interceptor() {
                    @Override
                    public okhttp3.Response intercept(Chain chain) throws IOException {
                        Request original = chain.request();

                        // Customize the request
                        Request request = original.newBuilder()
                                .header("Content-Type", "application/json")
                                .removeHeader("Pragma")
                                .header("Cache-Control", String.format("max-age=%d", BuildConfig.CACHETIME))
                                .build();

                        okhttp3.Response response = chain.proceed(request);
                        response.cacheResponse();
                        // Customize or return the response
                        return response;
                    }
                })
                .cache(cache)

                .build();

        return new Retrofit.Builder()
                .baseUrl(BuildConfig.BASEURL)
                .client(okHttpClient)
                .addConverterFactory(GsonConverterFactory.create())
                .addConverterFactory(ScalarsConverterFactory.create())
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())

                .build();
    }

    @Provides
    @Singleton
    @SuppressWarnings("unused")
    public NetworkService providesNetworkService(
            Retrofit retrofit) {
        return retrofit.create(NetworkService.class);
    }
    @Provides
    @Singleton
    @SuppressWarnings("unused")
    public RetrieverService providesService(
            NetworkService networkService) {
        return new RetrieverService(networkService);
    }

}

```

Dependencies in grade file:

```
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
    implementation 'com.android.support:recyclerview-v7:28.0.0-rc02'
    implementation 'com.android.support:cardview-v7:28.0.0-rc02'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.squareup.retrofit2:retrofit:2.4.0'
    implementation 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
    implementation 'com.squareup.retrofit2:converter-scalars:2.1.0'
    implementation 'io.reactivex:rxandroid:1.2.1'
    implementation 'io.reactivex:rxjava:1.1.6'
    implementation 'com.github.bumptech.glide:glide:4.3.1'

    //dagger 2
    implementation 'com.google.dagger:dagger:2.14.1'
    annotationProcessor 'com.google.dagger:dagger-compiler:2.14.1'

    //to enable DaggerActivity, DaggerBroadcastReceiver, DaggerFragment etc classes
    implementation 'com.google.dagger:dagger-android:2.14.1'
    annotationProcessor 'com.google.dagger:dagger-android-processor:2.14.1'

    //support libraries with dagger 2
    implementation 'com.google.dagger:dagger-android-support:2.14.1'

    compileOnly 'javax.annotation:jsr250-api:1.0'
    compileOnly 'org.glassfish:javax.annotation:10.0-b28'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

```

To fix this, I also tried enabling the annotation processing by going into File -> Other Settings -> Default Settings -> Build, Execution, Deployments -> Annotation Processors.

[![enter image description here](https://i.stack.imgur.com/rvY6v.png)](https://i.stack.imgur.com/rvY6v.png)

Not sure what else can I do to fix it. Am I missing something else here? I thought adding the dependencies in grade file will fix it, but it didn't.

Edit: Adding in main activity class and image activity class.

main\_activity:

```
package com.mario.photoapp;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.mario.photoapp.dependency.Dependency;
import com.mario.photoapp.services.NetworkModule;

import java.io.File;

public class MainActivity extends AppCompatActivity {
    Dependency dependency;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        File cacheFile = new File(getCacheDir(), "responses");
        dependency = DaggerDependency.builder.networkModule(new NetworkModule(cacheFile)).build();
    }

    public Dependency getDependency() {
        return dependency;
    }
}

```

Image activity class:

```
package com.mario.photoapp.photoalbum;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.Toast;

import com.mario.photoapp.MainActivity;
import com.mario.photoapp.R;
import com.mario.photoapp.models.ImageListData;
import com.mario.photoapp.models.ImageListResponse;
import com.mario.photoapp.services.RetrieverService;

import javax.inject.Inject;

public class ImageActivity extends MainActivity implements ImageViewInterface {

    private RecyclerView list;
    @Inject
    public  RetrieverService service;
    ProgressBar progressBar;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getDependency().inject(this);

        setContentView(R.layout.activity_main);
        list = findViewById(R.id.list);
        progressBar = findViewById(R.id.progress);

        list.setLayoutManager(new LinearLayoutManager(this));

        ImagePresenter presenter = new ImagePresenter(service, this);
        presenter.getCityList();
    }

    @Override
    public void showWait() {
        progressBar.setVisibility(View.VISIBLE);
    }

    @Override
    public void removeWait() {
        progressBar.setVisibility(View.GONE);
    }

    @Override
    public void onFailure(String appErrorMessage) {

    }

    @Override
    public void getCityListSuccess(ImageListResponse imageListResponse) {

        ImageAdapter adapter = new ImageAdapter(getApplicationContext(), imageListResponse.getData(),
                new ImageAdapter.OnItemClickListener() {
                    @Override
                    public void onClick(ImageListData Item) {
                        Toast.makeText(getApplicationContext(), Item.getName(),
                                Toast.LENGTH_LONG).show();
                    }
                });

        list.setAdapter(adapter);

    }
}

```