【发布时间】:2021-12-29 05:46:41
【问题描述】:
无法在 android studio 中使用 kotlin 范围函数,显示未解析的引用。 工作室版本:北极狐2020.3.1补丁4
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-android-extensions'
id 'kotlin-kapt'
id 'dagger.hilt.android.plugin'
}
def HILT_VERSION ="2.38.1"
def NAV_VERSION = "2.3.5"
def RETROFIT_VERSION = "2.9.0"
def OKHTTP_VERSION = "4.9.0"
android {
compileSdk 31
defaultConfig {
applicationId "com.example.ezcart"
minSdk 21
targetSdk 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
dataBinding {
enabled true
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation "com.google.dagger:hilt-android:$HILT_VERSION"
kapt "com.google.dagger:hilt-android-compiler:$HILT_VERSION"
implementation "androidx.navigation:navigation-fragment-ktx:$NAV_VERSION"
implementation "androidx.navigation:navigation-ui-ktx:$NAV_VERSION"
implementation "com.squareup.retrofit2:retrofit:$RETROFIT_VERSION"
// Retrofit with Gson Converter
implementation "com.squareup.retrofit2:converter-gson:$RETROFIT_VERSION"
implementation 'com.google.code.gson:gson:2.8.9'
implementation "com.squareup.okhttp3:okhttp:$OKHTTP_VERSION"
implementation "com.squareup.okhttp3:logging-interceptor:$OKHTTP_VERSION"
//Glide
implementation 'com.github.bumptech.glide:glide:4.12.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
【问题讨论】: