Nee*_*ani 12 android kotlin kotlin-coroutines
好像kotlinx协同程序测试的依赖是不是为我工作,我可以像依赖的不是访问成员TestCoroutineDispatcher,setMain(),resetMain()等我下这个文档,但尽管添加gradle这个依赖无法访问的成员。我尝试重建项目并使缓存无效并重新启动,但似乎没有任何效果。我也尝试过,androidExtensions {experimental = true}但仍然没有运气。
构建.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.android.kotlincoroutines"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
androidExtensions {
experimental = true
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.1'
implementation 'androidx.appcompat:appcompat:1.1.0-alpha02'
implementation 'com.google.android.material:material:1.1.0-alpha03'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
// ViewModel and LiveData
def lifecycle_version = '2.0.0-beta01'
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.1.0-alpha02"
testImplementation "androidx.arch.core:core-testing:$lifecycle_version"
// Room for database
def room_version = '2.0.0'
implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version"
def work_version = "1.0.0-rc01"
implementation "android.arch.work:work-runtime:$work_version"
androidTestImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test:rules:1.1.1'
androidTestImplementation "com.google.truth:truth:0.42"
androidTestImplementation "androidx.arch.core:core-testing:$lifecycle_version"
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.3.0-M1'
}
Run Code Online (Sandbox Code Playgroud)
我哪里出错了?
将您的库版本更改为1.3.2而不是1.3.0-M1这样:
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.3.2'
Run Code Online (Sandbox Code Playgroud)
并确保您的测试unit test在test文件夹中,而不是instrumented test在androidTest文件夹中。
| 归档时间: |
|
| 查看次数: |
1933 次 |
| 最近记录: |