Skip to content

Instantly share code, notes, and snippets.

@tomoya0x00
Created September 13, 2019 09:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomoya0x00/05125f5b9320084e9d5cba1e1829d564 to your computer and use it in GitHub Desktop.
Save tomoya0x00/05125f5b9320084e9d5cba1e1829d564 to your computer and use it in GitHub Desktop.
codelabs_kotlin_coroutines
/*
* Copyright 2018 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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'
}
}
compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
kotlinOptions {
jvmTarget = "1.8"
}
}
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"
testImplementation "androidx.test:core:1.0.0"
// Room for database
def room_version = '2.0.0'
implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version"
implementation "androidx.work:work-runtime-ktx:2.2.0"
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.test:core:1.0.0"
androidTestImplementation "androidx.arch.core:core-testing:$lifecycle_version"
androidTestImplementation "androidx.work:work-testing:2.2.0"
}
@punchdrunker
Copy link

いまさらですけど、これでも、6ページ目のexperimentalなところのコードが動かないですね。
変数名がdispatcherと書いてあるところはtestDispatcherが正しいのと、もう1つ
build.gradleに

testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.3.1'
androidTestImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.3.1'

の2行が必要で、バージョンを合わせる為にkotlinx-coroutines-coreも

implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.1'

に変更が必要そう

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment