将Android Studio更新到2020.3.1 Canary 14 Build后未解决的Kotlin参考 [英] Unresolved Kotlin references after updating Android Studio to 2020.3.1 Canary 14 Build
问题描述
我目前正在体验Android Studio,警告我某些不存在的Kotlin功能.我认为这是一个仅限Android Studio的问题,因为我可以正常编译和运行项目
I am currently experiencing Android Studio warning me about certain Kotlin functions that don't exist. I assume this is an Android Studio only problem as I can compile and run my project just fine
例如,Android Studio无法识别 val行= mutableListOf< MeasuredRow>()
.它提供警告:未解决的引用:mutableListOf
.也就是说,我可以使用其他一些Kotlin函数和类.
For example, Android Studio is unable to recognize val rows = mutableListOf<MeasuredRow>()
. It provides the warning: Unresolved reference: mutableListOf
. That said, I can use some other Kotlin functions and classes just fine.
唯一的解决方案是降级我不想要做的
The only solution is downgrading which I do not want to do
应用范围内的gradle:
App-wide gradle:
buildscript {
ext.kotlin_version = "1.4.32"
ext.compose_version = '1.0.0-beta04'
ext.hilt_version = '2.33-beta'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.0-alpha14'
classpath "com.google.dagger:hilt-android-gradle-plugin:$hilt_version"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
mavenCentral()
jcenter()
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlinOptions {
jvmTarget = '1.8'
allWarningsAsErrors = false
// Opt-in to experimental compose APIs
freeCompilerArgs += '-Xopt-in=kotlin.RequiresOptIn'
// Enable experimental coroutines APIs, including collectAsState()
freeCompilerArgs += '-Xopt-in=kotlinx.coroutines.ExperimentalCoroutinesApi'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
特定于应用模块的Gradle:
App module specific Gradle:
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
id 'dagger.hilt.android.plugin'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.test"
minSdkVersion 23
targetSdkVersion 30
versionCode 1
versionName "1.0"
}
buildscript {
apply from: '../dependencies.gradle'
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion '1.0.0-beta04'
}
buildTypes {
release {
minifyEnabled true
debuggable false
shrinkResources = true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation "androidx.compose.compiler:compiler:1.0.0-beta04"
implementation 'androidx.compose.ui:ui:1.0.0-beta04'
implementation 'androidx.compose.ui:ui-tooling:1.0.0-beta04'
implementation 'androidx.compose.foundation:foundation:1.0.0-beta04'
implementation 'androidx.compose.material:material:1.0.0-beta04'
implementation 'androidx.activity:activity-compose:1.3.0-alpha06'
implementation 'androidx.compose.runtime:runtime-livedata:1.0.0-beta04'
implementation "androidx.navigation:navigation-compose:1.0.0-alpha09"
implementation "androidx.hilt:hilt-navigation-compose:1.0.0-alpha01"
implementation 'dev.chrisbanes.accompanist:accompanist-insets:0.6.2'
// ViewModel
def lifecycle_version = "2.3.1"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:1.0.0-alpha04'
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
// hilt
implementation "com.google.dagger:hilt-android:$hilt_version"
kapt "com.google.dagger:hilt-compiler:$hilt_version"
// Image Loading
implementation group: 'com.google.accompanist', name: 'accompanist-imageloading-core', version: '0.7.0'
implementation "com.google.accompanist:accompanist-glide:0.7.0"
}
重要的是要知道我的应用程序可以正常运行并且可以无问题安装(即使是全新安装)
It is important to know that my app works and is installable with no issues (even on a clean install)
我尝试过的事情:
- 重新安装Windows PC
- 使缓存/重启无效
- 在主目录中删除.android studio
- 删除./.idea文件夹
推荐答案
现在对我有效.
AS 2020.3.1金丝雀15
AS 2020.3.1 canary 15
科特林1.5.0
这篇关于将Android Studio更新到2020.3.1 Canary 14 Build后未解决的Kotlin参考的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!