6thsolution / EasyMVP

A full-featured framework that allows building android applications following the principles of Clean Architecture.
http://6thsolution.github.io/EasyMVP
Apache License 2.0
1.3k stars 129 forks source link

Cannot access ParametersAreNullableByDefault #15

Closed RiccardoM closed 7 years ago

RiccardoM commented 7 years ago

I've tried to create the following presenter:

public class MainPresenter extends RxPresenter<MainView> {

    private MainView view;

    private GetRandomContactUseCase getRandomContact;

    @Inject
    public MainPresenter(GetRandomContactUseCase getRandomContact){
        this.getRandomContact = getRandomContact;
    }

    ...

}

With java GetRandomContactUseCase being:

public class GetRandomContactUseCase extends ObservableUseCase<String, Void> {

    ContactsDataSource source;

    @Inject
    public GetRandomContactUseCase(ContactsDataSource source,
                                   UseCaseExecutor executor,
                                   PostExecutionThread executionThread){
        super(executor, executionThread);
        this.source = source;
    }

    @Override
    protected Observable<String> interact(Void param) {
        return Observable.just(source.getRandomContact());
    }
}

When I try to compile this, i get the following error:

Error:cannot access ParametersAreNullableByDefault  
Error:Execution failed for task ':module:compileReleaseJavaWithJavac'.  
> Compilation failed; see the compiler error output for details.

Using the following UseCase, which does not extend ObservableUseCase, however, I don't get any error:

public class GetRandomContactUseCase {

    ContactsDataSource source;

    @Inject
    public GetRandomContactUseCase(ContactsDataSource source,
                                   UseCaseExecutor executor,
                                   PostExecutionThread executionThread){
        this.source = source;
    }

I think that this is due to ObservableUseCase having no default constructor, or no constructor marked as @Inject. Is there a way you can fix this issue, maybe creating a plugin which has all classes with a constructor marked with @Inject if that is the error, or having an empty constructor?

RiccardoM commented 7 years ago

@SaeedMasoumi I checked for the error, and it looks like the problem is inside the ObservableUseCase<Q, R> class, specifically on line 36 and 41, when using the @ParametersAreNullableByDefault annotation. It looks like this annotation is no more supported, and so can't be found, making impossibile for the application to build nor make.

SaeedMasoumi commented 7 years ago

@RiccardoM @ParametersAreNullableByDefault annotation is a part of jsr305 , Did you have com.google.code.findbugs:jsr305library inside your dependencies? (also @ParametersAreNullableByDefault is not available in old versions of findbugs)

Also I write a test for ObservableUseCase, take a look at build.gradle and IsNumberOdd class in easymvp-test module.

SaeedMasoumi commented 7 years ago

@RiccardoM Also try to add

android{
....
}
configurations.all {
            resolutionStrategy {
                force 'com.google.code.findbugs:jsr305:1.3.9', 'com.google.code.findbugs:jsr305:2.0.1'
            }
}

In your build.gradle, it will force to use the latest version of findbugs