我正在使用 Viper MVP 代码架构 -
当我编译代码时,我收到了这个错误-
Error:(32, 10) error: com.tv.goin.activities.login.LoginMvpPresenter<com.tv.goin.activities.logi n.LoginMvpView,com.tv.goin.activities.login.LoginMvpInteractor>
cannot be provided without an @Provides- or @Produces-annotated method.
com.tv.goin.activities.login.LoginMvpPresenter<com.tv.goin.activities.login.LoginMvpView,com.tv.goin.activities.login.LoginMvpInteractor> is injected at
com.tv.goin.activities.login.LoginActivity.mPresenter
com.tv.goin.activities.login.LoginActivity is injected at
com.tv.goin.di.component.ActivityComponent.inject(activity)
这是我的 Gradle 文件-
apply plugin: 'com.android.application'
//apply plugin: 'com.neenbedankt.android-apt'
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
applicationId "com.tv.goin"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
debug {
buildConfigField("String", "BASE_URL", "\"http://www.mocky.io/v2\"")
buildConfigField("String", "API_KEY", "\"ABCXYZ123TEST\"")
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField("String", "BASE_URL", "\"http://www.mocky.io/v2\"")
buildConfigField("String", "API_KEY", "\"ABCXYZ123TEST\"")
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// android support libraries
compile "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
compile "com.android.support:recyclerview-v7:$rootProject.supportLibraryVersion"
compile "com.android.support:cardview-v7:$rootProject.supportLibraryVersion"
compile "com.android.support:design:$rootProject.supportLibraryVersion"
compile "com.android.support:support-vector-drawable:$rootProject.supportLibraryVersion"
compile "com.android.support:animated-vector-drawable:$rootProject.supportLibraryVersion"
// font
compile "uk.co.chrisjenx:calligraphy:$rootProject.calligraphyVersion"
// network
compile "com.amitshekhar.android:rx2-android-networking:$rootProject.rx2FastAndroidNetworking"
// image
compile "com.github.bumptech.glide:glide:$rootProject.glideVersion"
// parser
compile "com.google.code.gson:gson:$rootProject.gsonVersion"
// database
compile "org.greenrobot:greendao:$rootProject.greenDaoVersion"
// debug database
debugCompile "com.amitshekhar.android:debug-db:$rootProject.debugDBVersion"
// dependency injection
compile "com.google.dagger:dagger:$rootProject.dagger2Version"
annotationProcessor "com.google.dagger:dagger-compiler:$rootProject.dagger2Version"
provided 'javax.annotation:jsr250-api:1.0'
compile 'javax.inject:javax.inject:1'
// reactive
compile "io.reactivex.rxjava2:rxjava:$rootProject.rxjava2Version"
compile "io.reactivex.rxjava2:rxandroid:$rootProject.rxandroidVersion"
// code generator for view
compile "com.jakewharton:butterknife:$rootProject.butterKnifeVersion"
annotationProcessor "com.jakewharton:butterknife-compiler:$rootProject.butterKnifeVersion"
// swipe view
compile "com.mindorks:placeholderview:$rootProject.placeholderviewVersion"
// logger
compile "com.jakewharton.timber:timber:$rootProject.timberVersion"
// dependencies for local unit tests
testCompile "junit:junit:$rootProject.ext.junitVersion"
testCompile "org.mockito:mockito-core:$rootProject.mockitoVersion"
testAnnotationProcessor "com.google.dagger:dagger-compiler:$rootProject.dagger2Version"
// UI Testing
androidTestCompile "com.android.support.test.espresso:espresso-core:$rootProject.espressoVersion"
androidTestCompile "com.android.support.test.espresso:espresso-intents:$rootProject.espressoVersion"
androidTestCompile "org.mockito:mockito-core:$rootProject.mockitoVersion"
androidTestAnnotationProcessor "com.google.dagger:dagger-compiler:$rootProject.dagger2Version"
}
configurations.all {
resolutionStrategy.force "com.android.support:support-annotations:$supportLibraryVersion"
}
这是我的根级 Gradle -
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
// classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
// Define versions in a single place
ext {
// Sdk and tools
minSdkVersion = 16
targetSdkVersion = 25
compileSdkVersion = 25
buildToolsVersion = '25.0.2'
// App dependencies
supportLibraryVersion = '25.3.1'
gsonVersion = '2.8.0'
calligraphyVersion = '2.2.0'
glideVersion = '3.7.0'
rx2FastAndroidNetworking = '1.0.0'
dagger2Version = '2.8'
rxjava2Version = '2.0.6'
rxandroidVersion = '2.0.1'
butterKnifeVersion = '8.6.0'
greenDaoVersion = '3.2.0'
placeholderviewVersion = '0.6.1'
debugDBVersion = '1.0.0'
timberVersion = '4.5.1'
//Test dependencies
junitVersion = '4.12'
espressoVersion = '2.2.2'
mockitoVersion = '2.7.1'
}
编辑
LoginMvpPresenter 类
包 com.tv.goin.activities.login;
import com.tv.goin.BaseClasses.MvpPresenter; import com.tv.goin.di.PerActivity; /** * Created by Shoeb on 26/7/17. */ @PerActivity public interface LoginMvpPresenter<V extends LoginMvpView, I extends LoginMvpInteractor> extends MvpPresenter<V,I> { }