Android Gradle 下载库不完整

标签 android kotlin gradle

我有一个带有 Gradle 版本 6.6.1、Android Gradle 插件 4.2.0-alpha10 和 Kotlin 1.4.0 的 Android 项目。
然后我注意到 kotlin 标准库中缺少一些函数和类。
这是 Kotlin 库:
Missing functions and classes
这是 kotlin-stdlib 实现:

implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
有谁知道这个问题并知道如何解决这个问题?
编辑
buildscript {
    ext.kotlin_version = "1.4.0"
    repositories {
        google()
        jcenter()
        maven { url = "https://dl.bintray.com/kotlin/kotlin-eap/" }

        maven { url "https://maven.google.com/" }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.2.0-alpha10'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "org.jetbrains.kotlin:kotlin-allopen:$kotlin_version"
        classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.3.0"

        classpath 'com.google.gms:google-services:4.3.3'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.2.1'
        classpath 'com.google.dagger:hilt-android-gradle-plugin:2.28-alpha'
        //classpath 'com.google.firebase:perf-plugin:1.3.1'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url "https://jitpack.io" }
        maven { url "https://maven.google.com/" }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
=====
plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id 'kotlin-kapt'
    id 'kotlin-allopen'
    id 'kotlin-android-extensions'
    id 'androidx.navigation.safeargs.kotlin'
    id 'com.google.gms.google-services'
    id 'com.google.firebase.crashlytics'
    id 'dagger.hilt.android.plugin'
    //id 'com.google.firebase.firebase-perf'
}

allOpen {
    annotation 'XXXXXX'
}
android {
    compileSdkVersion 30
    buildToolsVersion "29.0.3"

    defaultConfig {
        applicationId "XXXXXX"
        minSdkVersion 27
        targetSdkVersion 30
        versionCode 1
        versionName "2.0.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        javaCompileOptions {
            annotationProcessorOptions {
                arguments += [
                        "room.schemaLocation": "$projectDir/schemas".toString(),
                        "room.incremental": "true",
                        "room.expandProjection": "true"
                ]
            }
        }
        multiDexEnabled false
    }
    signingConfigs {
        prod {
            keyAlias 'SM'
            keyPassword KEY_PASSWORD
            storeFile file('XXXXXXX')
            storePassword KEY_PASSWORD
        }
        dev {
            keyAlias 'SM'
            keyPassword KEY_PASSWORD
            storeFile file('XXXXXXX')
            storePassword KEY_PASSWORD
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = "1.8"
        freeCompilerArgs += '-Xopt-in=kotlin.RequiresOptIn'
    }
    buildTypes {
        release {
            debuggable true
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
        debug {
            minifyEnabled false
        }
    }
   flavorDimensions "version"
   productFlavors {
       prod {
           dimension "version"
           signingConfig signingConfigs.prod
       }
       dev {
           dimension "version"
           applicationIdSuffix ".dev"
           versionNameSuffix "-dev"
           signingConfig signingConfigs.dev
           proguardFile 'proguard-rules-dev.pro'
       }
   }
   variantFilter { variant ->
       def names = variant.flavors*.name

       if (names.contains("prod") && variant.buildType.name == "debug") {
           variant.ignore = true
       }
   }
    buildFeatures {
        dataBinding = true
        viewBinding = true
    }
    packagingOptions {
        exclude 'META-INF/atomicfu.kotlin_module'
    }
    dexOptions {
        preDexLibraries true
        javaMaxHeapSize "4g"
    }
    androidExtensions {
        experimental = true
    }
}

dependencies {
    implementation project(':cache')
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.7"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.5"


    // MIKEPENZ
    implementation 'com.mikepenz:materialdrawer:8.0.3'
    implementation "com.mikepenz:materialdrawer-nav:8.0.3"
    implementation "com.mikepenz:materialdrawer-iconics:8.0.3"
    implementation 'com.mikepenz:itemanimators:1.1.0'
    implementation 'com.mikepenz:iconics-core:5.0.3'
    implementation "com.mikepenz:iconics-views:5.0.3"
    implementation 'com.mikepenz:fontawesome-typeface:5.9.0.0-kotlin@aar'

    implementation "com.mikepenz:fastadapter:5.2.2"
    implementation "com.mikepenz:fastadapter-extensions-binding:5.2.2"
    implementation "com.mikepenz:fastadapter-extensions-diff:5.2.2"
    implementation "com.mikepenz:fastadapter-extensions-scroll:5.2.2"
    implementation "com.mikepenz:fastadapter-extensions-ui:5.2.2"
    implementation "com.mikepenz:fastadapter-extensions-utils:5.2.2"
    // mikepenz

    implementation 'com.timehop.stickyheadersrecyclerview:library:0.4.3@aar'

    // ANDROIDX
    implementation 'androidx.core:core-ktx:1.3.1'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation "androidx.recyclerview:recyclerview:1.1.0"
    kapt "androidx.annotation:annotation:1.1.0"
    implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.gridlayout:gridlayout:1.0.0'
    implementation 'androidx.viewpager2:viewpager2:1.0.0'
    implementation "androidx.navigation:navigation-fragment-ktx:2.3.0"
    implementation "androidx.navigation:navigation-ui-ktx:2.3.0"
    implementation "androidx.preference:preference-ktx:1.1.1"

    implementation "androidx.work:work-runtime-ktx:2.4.0"
    implementation "androidx.work:work-rxjava2:2.4.0"
    // androidx

    // GOOGLE
    implementation "com.google.android.material:material:1.3.0-alpha02"
    implementation 'com.google.android:flexbox:2.0.0'
    //implementation 'com.google.android.gms:play-services-auth:18.1.0'
    // google

    // ROOM
    implementation "androidx.room:room-runtime:2.2.5"
    implementation "androidx.room:room-ktx:2.2.5"
    implementation "androidx.room:room-rxjava2:2.2.5"
    kapt "androidx.room:room-compiler:2.2.5"
    androidTestImplementation "androidx.room:room-testing:2.2.5"
    // room

    implementation "io.reactivex.rxjava2:rxjava:2.2.19"
    implementation "io.reactivex.rxjava2:rxandroid:2.1.1"
    implementation 'me.dm7.barcodescanner:zxing:1.9.13'
    implementation 'com.karumi:dexter:6.2.1'

    implementation 'com.google.code.gson:gson:2.8.6'

    // LIFECYCLE
    implementation "androidx.lifecycle:lifecycle-common-java8:2.2.0"
    implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0"
    implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.2.0"
    implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.2.0"
    implementation "androidx.lifecycle:lifecycle-reactivestreams-ktx:2.2.0"
    androidTestImplementation "androidx.arch.core:core-testing:2.1.0"
    // lifecycle

    // DAGGER
    /*
    implementation 'com.google.dagger:dagger:2.28.3'
    kapt 'com.google.dagger:dagger-compiler:2.28.3'
    implementation 'com.google.dagger:dagger-android:2.25.2'
    implementation 'com.google.dagger:dagger-android-support:2.25.2'
    kapt 'com.google.dagger:dagger-android-processor:2.25.2'
     */

    implementation 'com.google.dagger:hilt-android:2.28.3-alpha'
    kapt 'com.google.dagger:hilt-android-compiler:2.28.3-alpha'

    implementation 'androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha02'
    implementation 'androidx.hilt:hilt-work:1.0.0-alpha02'
    kapt 'androidx.hilt:hilt-compiler:1.0.0-alpha02'
    // dagger

    implementation "com.airbnb.android:lottie:3.4.2"

    implementation 'com.jakewharton.timber:timber:4.7.1'

    implementation 'com.squareup.retrofit2:retrofit:2.9.0'
    implementation 'com.squareup.retrofit2:converter-moshi:2.9.0'
    implementation 'com.squareup.moshi:moshi-kotlin:1.10.0'
    implementation 'com.squareup.moshi:moshi-adapters:1.10.0'
    implementation "com.squareup.okhttp3:logging-interceptor:4.8.1"
    kapt 'com.squareup.moshi:moshi-kotlin-codegen:1.10.0'
    testImplementation "com.squareup.okhttp3:mockwebserver:4.8.1"

    implementation 'me.dm7.barcodescanner:zxing:1.9.13'
    implementation "androidx.fragment:fragment-ktx:1.2.5"
    implementation "io.noties.markwon:core:4.5.1"
    implementation 'commons-net:commons-net:20030805.205232'
    implementation 'commons-codec:commons-codec:1.6'
    implementation 'id.zelory:compressor:3.0.0'

    implementation 'com.github.ongakuer.circleindicator:LoopingViewPager:2.1.4'
    implementation 'me.relex:circleindicator:2.1.4'

    implementation 'me.zhanghai.android.materialprogressbar:library:1.6.1'

    implementation 'com.github.stfalcon:stfalcon-imageviewer:1.0.1'
    implementation 'com.github.bumptech.glide:glide:4.11.0'
    kapt 'com.github.bumptech.glide:compiler:4.11.0'

    implementation 'com.google.code.gson:gson:2.8.6'

    implementation 'com.google.firebase:firebase-analytics-ktx:17.5.0'
    implementation 'com.google.firebase:firebase-crashlytics:17.2.1'
    implementation('com.google.firebase:firebase-ml-vision:24.1.0') {
        exclude group: 'com.google.android.gms', module: 'play-services-vision'
    }
    implementation ('com.google.firebase:firebase-ml-vision-barcode-model:16.1.2') {
        exclude group: 'com.google.android.gms', module: 'play-services-vision'
    }
    //implementation 'com.google.firebase:firebase-ml-vision-object-detection-model:19.0.5'
    //implementation 'com.google.firebase:firebase-perf:19.0.8'
    implementation 'com.google.firebase:firebase-config-ktx:19.2.0'
    implementation 'com.google.firebase:firebase-messaging:20.2.4'

    //debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.1'

    debugImplementation "com.github.chuckerteam.chucker:library:3.2.0"

    releaseImplementation "com.github.chuckerteam.chucker:library-no-op:3.2.0"

    testImplementation 'junit:junit:4.13'
    testImplementation 'androidx.test:core-ktx:1.3.0'
    testImplementation 'org.mockito:mockito-core:3.3.3'
    testImplementation 'org.mockito:mockito-inline:2.13.0'
    testImplementation 'com.google.dagger:hilt-android-testing:2.28.3'
    kaptTest 'com.google.dagger:hilt-android-compiler:2.28.3'
    androidTestImplementation 'org.mockito:mockito-android:2.19.0'
    androidTestImplementation 'androidx.test:runner:1.3.0'
    androidTestImplementation 'androidx.test:rules:1.3.0'
    androidTestImplementation 'org.hamcrest:hamcrest-library:2.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
    androidTestImplementation 'androidx.test.espresso:espresso-intents:3.3.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
    androidTestImplementation 'androidx.test.ext:junit-ktx:1.1.2'
    androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
    androidTestImplementation  'com.google.dagger:hilt-android-testing:2.28.3'
    kaptAndroidTest 'com.google.dagger:hilt-android-compiler:2.28.3'
}

最佳答案

Kotlin 插件 1.4.0 不支持 Android Studio 4.2。对于 AS 4.2,请使用插件的 1.4.10 版本。
您可以尝试这两个选项来安装它。

  • 尝试从 android studio settings 安装它
  • here 手动下载并从磁盘安装

  • 您可以直接在 Gradle 文件上更改版本,它会起作用。但是 AS 会提示与 bundle 版本的差异。

    关于Android Gradle 下载库不完整,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63810644/

    相关文章:

    Android:无法访问 DrawerLayout 中的 MenuItem

    Android NFC 与 Mifare DESFire EV1 通信

    java - 车速表 Android 应用程序无法进行公里/小时转换?

    java - Google Play要求从受影响的应用中删除Install_referrer

    android - 应用级别的gradle文件中flutterversionNameflutterVersionCode的flutter问题

    java.sql.SQLException : No suitable driver found for jdbc:mariadb in a Gradle project (Intellij)

    android-studio - Libgdx 桌面版本无法编译

    android - repo 初始化一个特定的提交

    Android 将项目一个接一个地添加到 LinearLayout 中

    android - 在 Android 中使用 OpenCV 时遇到问题