[英]Kotlin 1.3.61 problem with Kotlin Coroutines in Android studio
問題已解決:發布在下面的答案部分
問題
將 kotlin 版本升級到1.3.61
。 我不能使用withContext
, Dispatchers IO, Main
沒有工作。 它顯示未解析的參考。 kotlin 的新更新是否有任何錯誤? 或者是什么? 因為之前一切正常。
我已經打開了我的舊項目與每個協程函數相同的錯誤unresolved reference
,就像我說的withContext()
等。但是當我嘗試調用另一個suspend
函數時, suspend
關鍵字正在使用很少的協程圖標/標記顯示。
我嘗試什么?
將 kotlin 版本降級到1.3.50
或嘗試升級協程版本1.3.61
(這很愚蠢)但沒有任何效果..
不斷地尋找,但不幸的是找不到任何修復。
創建了一個新項目並嘗試在onCreate()
方法中使用但仍然相同。
編輯:
添加等級:
build.gradle(模塊:應用程序)
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(項目: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
}
我在 kotlin 1.3.60 上,但在看到這個問題后升級到 1.3.61 以調試您的問題。
升級后,沒有任何錯誤。
嘗試使 android studio 緩存無效並重新啟動您的 android studio 。 這可能是 android studio 緩存問題。
讓我知道它是否對你有用。
通過單擊左上角的文件選項卡來執行此操作,然后向下滾動以使緩存無效/重新啟動並單擊
使固定:
當我發現我的一些其他東西像some::class.java
在這里java
是未解決的錯誤。 然后我簡單地跳入xml
並嘗試添加一些小部件以確保 xml 的行為方式,他們沒有添加意味着他們的屬性沒有像自動完成那樣顯示,但幸運的是我已經修復了這個問題。 我認為它可能會發生,因為它解決了我的所有問題。
這是您只需要做的事情,順便說一下,它是通過 android studio 子文件夾向某些文件夾添加.bak
擴展名的方式,它是:
https://stackoverflow.com/a/54007742/12397978
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.