ISSUE SOLVED: posted in answer section below
Problem
After upgrading kotlin version to 1.3.61. I am not be able use withContext, Dispatchers IO, Main nothing is working. It's showing unresolved reference. Are there any bugs in new update of kotlin? or what? cause everything was working fine before.
I have opened my old projects same error unresolved reference with every Coroutine functions like i said withContext() etc. But suspend keyword is working with little coroutine icon/mark is showing as well, when i try to call another suspend function.
What i try?
Downgraded kotlin version to 1.3.50 or try to upgrade coroutine version 1.3.61 (which was silly) but nothing worked..
Continously trying to find but unfortunately couldn't find any fix.
Made a new project and tried to use in onCreate() method but still same.
EDIT:
Adding gradles:
build.gradle(Module:app)
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 28
buildToolsVersion "29.0.0"
defaultConfig {
applicationId "com.example.daggerpractise"
minSdkVersion 22
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
//Dagger 2
implementation 'com.google.dagger:dagger:2.15'
kapt 'com.google.dagger:dagger-compiler:2.15'
// For android
implementation 'com.google.dagger:dagger-android:2.15'
implementation 'com.google.dagger:dagger-android-support:2.15'
// if you use the support libraries
kapt 'com.google.dagger:dagger-android-processor:2.15'
// AndroidX support design (for nav drawer)
// def material_version = "1.0.0-rc02"
def material_version = "1.0.0"
implementation "com.google.android.material:material:$material_version"
implementation 'com.github.bumptech.glide:glide:4.10.0'
kapt 'com.github.bumptech.glide:compiler:4.10.0'
//MVVM and livedata
implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'
// Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.6.1'
implementation 'com.squareup.retrofit2:converter-gson:2.6.1'
// RxJava
def rxjava_version = '2.1.1'
implementation "io.reactivex.rxjava2:rxjava:$rxjava_version"
// Rx-Retrofit Call Adapter
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.5.0'
// Retrofit call adapter
// Kotlin Android Coroutines
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.2'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.2'
}
build.gradle(Project: DaggerPractise)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.61'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}