gpt4 book ai didi

android - 将 Android Studio 更新到 2020.3.1 Canary 14 Build 后 Unresolved Kotlin 引用

转载 作者:行者123 更新时间:2023-12-03 17:22:17 28 4
gpt4 key购买 nike

我目前正在遇到 Android Studio 警告我某些不存在的 Kotlin 函数。我认为这是 Android Studio 唯一的问题,因为我可以很好地编译和运行我的项目
例如,Android Studio 无法识别 val rows = mutableListOf<MeasuredRow>() .它提供警告:Unresolved reference: mutableListOf .也就是说,我可以很好地使用其他一些 Kotlin 函数和类。
唯一的解决方案是降级,我不想这样做
应用范围的 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:
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"
}
重要的是要知道我的应用程序可以正常工作并且可以毫无问题地安装(即使是全新安装)
我试过的:
  • 重新安装 Windows 电脑
  • 使缓存无效/重新启动
  • 删除主目录下的.Android studio
  • 删除./.idea文件夹
  • 最佳答案

    它现在对我有用。
    AS 2020.3.1 金丝雀 15
    Kotlin 1.5.0

    关于android - 将 Android Studio 更新到 2020.3.1 Canary 14 Build 后 Unresolved Kotlin 引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67063239/

    28 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com