I'm trying to use Dagger2 in my project, but after installation I have an error:
Error:(14, 8) error: Scoping annotations are only allowed on concrete types and @Provides methods: ApplicationComponent
There are my Module and Component files:
import javax.inject.Singleton;
import dagger.Component;
@Singleton
@Component(modules = {ApplicationModule.class})
public interface ApplicationComponent {
void inject(BaseActivity activity);
Context context();
}
Module:
@Module
public class ApplicationModule {
public Context context;
public ApplicationModule(@NonNull Context context) {
this.context = context;
}
@Provides
@Singleton
Context provideApplicationContext() {
return this.context;
}
}
I use the follow dependences:
apt 'com.google.dagger:dagger-compiler:2.7'
compile 'com.google.dagger:dagger:2.7'
provided 'javax.annotation:jsr250-api:1.0'
Also, I have this error:
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> com.google.common.util.concurrent.ExecutionError: java.lang.NoSuchMethodError: dagger.internal.codegen.Util.isAnyAnnotationPresent(Ljavax/lang/model/element/Element;Ljava/lang/Iterable;)Z