Android Gradle下载库不完整

问题描述

我有一个Android项目,其中包含Gradle版本6.6.1,Android Gradle插件4.2.0-alpha10和Kotlin 1.4.0。 然后我注意到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版本。

您可以尝试使用这两个选项进行安装。

  1. 尝试从android studio settings

    开始安装
  2. here手动下载并从磁盘安装

您可以直接在Gradle文件上更改版本,它将起作用。但是AS会抱怨捆绑版本的差异。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...