Kotlin 1.3.61 Android studio中的Kotlin协同程序存在问题
问题已解决:发布在下面的回答部分Kotlin 1.3.61 Android studio中的Kotlin协同程序存在问题,android,android-studio,kotlin,kotlin-coroutines,Android,Android Studio,Kotlin,Kotlin Coroutines,问题已解决:发布在下面的回答部分 问题 将kotlin版本升级到1.3.61后。我无法在上下文中使用,调度程序IO,主无任何工作。它显示未解析的引用。kotlin的新更新中是否存在任何bug?还是怎样因为以前一切都很好。 我打开了我的旧项目,每个协同程序函数都出现了相同的错误未解决的引用,就像我说的withContext()等。但是suspend关键字正在工作,当我尝试调用另一个suspend函数时,小协同程序图标/标记也在显示。 我尝试了什么? 将kotlin版本降级为1.3.50或尝试升级协
问题
将kotlin版本升级到
1.3.61
后。我无法在上下文中使用,调度程序IO,主
无任何工作。它显示未解析的引用。kotlin的新更新中是否存在任何bug?还是怎样因为以前一切都很好。
我打开了我的旧项目,每个协同程序函数都出现了相同的错误未解决的引用
,就像我说的withContext()
等。但是suspend
关键字正在工作,当我尝试调用另一个suspend
函数时,小协同程序图标/标记也在显示。
我尝试了什么?
将kotlin版本降级为1.3.50
或尝试升级协同程序版本1.3.61
(这很愚蠢),但没有任何效果。
不断尝试查找,但不幸的是找不到任何修复程序。
创建了一个新项目并尝试在onCreate()
方法中使用,但仍然相同。
编辑:
添加渐变:
build.gradle(模块:应用程序)
build.gradle(项目:匕首实践)
我在kotlin 1.3.60上,但在看到此问题后升级到1.3.61,以便调试您的问题
升级后,没有出现任何错误
尝试使android studio缓存无效并重新启动android studio。这可能是android studio缓存问题
让我知道它是否对您有效。
单击左上角的文件选项卡,然后向下滚动以使缓存无效/重新启动,当我发现我的一些其他东西(如some::class.java
此处java
是未解决的错误时,单击修复:
。然后我简单地跳入xml
并尝试添加一些小部件,以确保xml的行为,它们没有添加意味着它们的属性没有像自动完成那样显示,但幸运的是,我已经解决了这个问题。我想这可能是因为它解决了我所有的问题。
这里是你必须要做的,顺便说一句,这是安卓studio子文件夹添加.bak
扩展到一些文件夹的一件事,无论如何,这里是:
你们是否都包括:implementation'org.jetbrains.kotlinx:kotlinx coroutines core:1.3.2'implementation'org.jetbrains.kotlinx:kotlinx coroutines android:1.3.2'?@NicolaGallazzi是的,两个都包括,但只有一次我删除了core
,但都不起作用please@NicolaGallazzi更新了,看一看。谢谢,做了两次,但都没用,还是一样。即使是withContext()
也没有显示在建议中,但当我尝试dispatchers.IO
时,IO显示为字符串,而它应该是协同路由调度程序。顺便说一句,你的立场是什么?升级后,工作正常吗?
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'
}
// 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
}