开始探索Espresso 2.0,但似乎遇到了打嗝.我无法让测试成功运行任何包含Dagger的项目.当我运行测试时,我得到以下异常(最后的整个堆栈跟踪):
java.lang.NoClassDefFoundError: com/pdt/daggerexample/model/DaggerExampleAppModule$$ModuleAdapter$ProvideMySingletonProvidesAdapter
Run Code Online (Sandbox Code Playgroud)
应用程序在未从AndroidInstrumentationTest运行时运行.
以下是一些相关文件,我还将项目上传到github,以便更快地结账/复制https://github.com/paul-turner/espressoDaggerExample.
的build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.pdt.daggerexample"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
minSdkVersion 16
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
}
}
packagingOptions {
exclude 'LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.jakewharton:butterknife:5.1.1'
compile 'com.squareup.dagger:dagger:1.2.2'
provided 'com.squareup.dagger:dagger-compiler:1.2.2' …Run Code Online (Sandbox Code Playgroud)