簡體   English   中英

Kotlin Scope 功能在 Android 工作室中不起作用

[英]Kotlin Scope functions not working in Android studio

無法在 android 工作室中使用 kotlin scope 函數,顯示未解決的參考。 工作室版:北極狐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'
}

要使用Kotlin函數,包括Scope 函數,請添加依賴項:

implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

這是Kotlin 標准庫,它通過Kotlin為日常工作提供生活必需品。 這些包括:

  • 實現慣用模式(讓、應用、使用、同步等)的高階函數。
  • 擴展函數為 collections (eager) 和序列 (lazy) 提供查詢操作。
  • 用於處理字符串和字符序列的各種實用程序。
  • JDK 類的擴展使處理文件、IO 和線程變得更加方便。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM