已应用Hilt Android Gradle插件,但未找到com.google.dagger:Hilt Android依赖项

已应用Hilt Android Gradle插件,但未找到com.google.dagger:Hilt Android依赖项,android,gradle,gradle-kotlin-dsl,dagger-hilt,Android,Gradle,Gradle Kotlin Dsl,Dagger Hilt,我收到这个gradle同步错误-应用了Hilt Android gradle插件,但没有找到com.google.dagger:Hilt Android依赖项。有人能帮忙吗?:) 我在使用kotlin dsl,我在buildSrc中有libs.kt object libs { object hilt { private const val dagger_hilt_version = "2.30.1-alpha"

我收到这个gradle同步错误-应用了Hilt Android gradle插件,但没有找到com.google.dagger:Hilt Android依赖项。有人能帮忙吗?:)

我在使用kotlin dsl,我在buildSrc中有libs.kt

object libs {
        object hilt {
            private const val dagger_hilt_version = "2.30.1-alpha"
            private const val jetpack_hilt_version = "1.0.0-alpha02"

            const val gradlePlugin = "com.google.dagger:hilt-android-gradle-plugin:$dagger_hilt_version"
            const val android = "com.google.dagger:hilt-android:$dagger_hilt_version"
            const val android_compiler = "com.google.dagger:hilt-android-compiler:$dagger_hilt_version"

            const val jetpack_viewmodel = "androidx.hilt:hilt-lifecycle-viewmodel:$jetpack_hilt_version"
            const val jetpack_compiler = "androidx.hilt:hilt-compiler:$jetpack_hilt_version"
        }

        /* more objects + more constants */

    }
buildSrc-build.gradle.kts:

plugins {
    `kotlin-dsl`
}

repositories {
    jcenter()
}
buildscript {
    repositories {
        google()
        mavenCentral()
        maven(url = "https://jitpack.io")
        maven(url = "https://repo1.maven.org/maven2/")
        maven(url = "https://plugins.gradle.org/m2/")
        maven(url = "https://github.com/userxpro/userx/raw/maven/")
        maven(url = "https://dl.bintray.com/kotlin/kotlin-eap/")
        maven(url = "https://dl.bintray.com/kotlin/kotlinx/")
        maven(url = "https://kotlin.bintray.com/kotlinx")
        maven(url = "https://oss.sonatype.org/content/repositories/snapshots")
        maven(url = "http://storage.googleapis.com/r8-releases/raw")
        gradlePluginPortal()
    }

    dependencies {
        classpath(libs.r8)

        classpath(libs.androidGradlePlugin)
        classpath(libs.kotlin.gradlePlugin)
        classpath(libs.hilt.gradlePlugin)

        classpath("com.google.gms:google-services:4.3.4")
        classpath("com.google.firebase:firebase-crashlytics-gradle:2.4.1")
        classpath("com.google.firebase:perf-plugin:1.3.4")
    }
}

subprojects {
    repositories {
        google()
        mavenCentral()
        maven(url = "https://jitpack.io")
        maven(url = "https://repo1.maven.org/maven2/")
        maven(url = "https://plugins.gradle.org/m2/")
        maven(url = "https://dl.bintray.com/kotlin/kotlin-eap/")
        maven(url = "https://dl.bintray.com/kotlin/kotlinx/")
        maven(url = "https://kotlin.bintray.com/kotlinx")
        maven(url = "https://oss.sonatype.org/content/repositories/snapshots")
        maven(url = "https://github.com/userxpro/userx/raw/maven/")
        jcenter()
    }

    tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
        kotlinOptions {
            // Treat all Kotlin warnings as errors
            //useIR = true

            //allWarningsAsErrors = true

            freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn"

            // Enable experimental coroutines APIs, including Flow
            freeCompilerArgs += "-Xopt-in=kotlinx.coroutines.ExperimentalCoroutinesApi"
            freeCompilerArgs += "-Xopt-in=kotlinx.coroutines.FlowPreview"
            freeCompilerArgs += "-Xopt-in=kotlin.Experimental"
            freeCompilerArgs += "-Xallow-jvm-ir-dependencies"

            // Set JVM target to 1.8
            jvmTarget = "1.8"
        }
    }
}
buildSrc中的libs.kt

object libs {
        object hilt {
            private const val dagger_hilt_version = "2.30.1-alpha"
            private const val jetpack_hilt_version = "1.0.0-alpha02"

            const val gradlePlugin = "com.google.dagger:hilt-android-gradle-plugin:$dagger_hilt_version"
            const val android = "com.google.dagger:hilt-android:$dagger_hilt_version"
            const val android_compiler = "com.google.dagger:hilt-android-compiler:$dagger_hilt_version"

            const val jetpack_viewmodel = "androidx.hilt:hilt-lifecycle-viewmodel:$jetpack_hilt_version"
            const val jetpack_compiler = "androidx.hilt:hilt-compiler:$jetpack_hilt_version"
        }

        /* more objects + more constants */

    }
我的应用build.gradle.kts看起来像:

plugins {
    id("com.android.application")
    id("kotlin-android")
    id("kotlin-kapt")
    id("dagger.hilt.android.plugin")
    id("androidx.navigation.safeargs.kotlin")
    id("com.google.firebase.crashlytics")
    id("com.google.gms.google-services")

    id("com.google.firebase.firebase-perf")
}

android {
    useLibrary("org.apache.http.legacy")

    compileSdkVersion = "30"

    dependenciesInfo {
        includeInApk = true
        includeInBundle = true
    }

    buildFeatures {
        dataBinding = true
        compose = true
    }

    defaultConfig {   
        vectorDrawables.useSupportLibrary = true

        applicationId = "aa.bb.cc"

        targetSdkVersion(30)
        minSdkVersion(21)

        versionCode = 1
        versionName = "1.0.0"
    }

    signingConfigs {
        register("configReleaseCZ").configure {
            /*hidden part*/
        }
    }

    bundle {
        language {
            enableSplit = false
        }
    }

    buildTypes {
        named("debug").configure {
            isDebuggable = true
            extra.set("enableCrashlytics", false)
        }
        named("release").configure {
            isShrinkResources = true
            isMinifyEnabled = true
            proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
            isDebuggable = false
            extra.set("enableCrashlytics", true)
            signingConfig = signingConfigs.getByName("configReleaseCZ")
        }
    }

    composeOptions {
        kotlinCompilerVersion = libs.kotlin.version
        kotlinCompilerExtensionVersion = libs.compose.version
    }

    lintOptions {
        isAbortOnError = false
    }
}

kapt {
    correctErrorTypes = true
}

dependencies {
    //implementation("com.google.dagger:hilt-android:2.30.1-alpha") 
    //kapt ("com.google.dagger:hilt-android-compiler:2.30.1-alpha") //this doesnt work wither

    implementation(libs.hilt.android)
    kapt(libs.hilt.android_compiler)

    implementation(libs.hilt.jetpack_viewmodel)
    kapt(libs.hilt.jetpack_compiler)

    /* many more dependencies */

}
kapt {
    correctErrorTypes = true
}
我的项目build.gradle.kts:

plugins {
    `kotlin-dsl`
}

repositories {
    jcenter()
}
buildscript {
    repositories {
        google()
        mavenCentral()
        maven(url = "https://jitpack.io")
        maven(url = "https://repo1.maven.org/maven2/")
        maven(url = "https://plugins.gradle.org/m2/")
        maven(url = "https://github.com/userxpro/userx/raw/maven/")
        maven(url = "https://dl.bintray.com/kotlin/kotlin-eap/")
        maven(url = "https://dl.bintray.com/kotlin/kotlinx/")
        maven(url = "https://kotlin.bintray.com/kotlinx")
        maven(url = "https://oss.sonatype.org/content/repositories/snapshots")
        maven(url = "http://storage.googleapis.com/r8-releases/raw")
        gradlePluginPortal()
    }

    dependencies {
        classpath(libs.r8)

        classpath(libs.androidGradlePlugin)
        classpath(libs.kotlin.gradlePlugin)
        classpath(libs.hilt.gradlePlugin)

        classpath("com.google.gms:google-services:4.3.4")
        classpath("com.google.firebase:firebase-crashlytics-gradle:2.4.1")
        classpath("com.google.firebase:perf-plugin:1.3.4")
    }
}

subprojects {
    repositories {
        google()
        mavenCentral()
        maven(url = "https://jitpack.io")
        maven(url = "https://repo1.maven.org/maven2/")
        maven(url = "https://plugins.gradle.org/m2/")
        maven(url = "https://dl.bintray.com/kotlin/kotlin-eap/")
        maven(url = "https://dl.bintray.com/kotlin/kotlinx/")
        maven(url = "https://kotlin.bintray.com/kotlinx")
        maven(url = "https://oss.sonatype.org/content/repositories/snapshots")
        maven(url = "https://github.com/userxpro/userx/raw/maven/")
        jcenter()
    }

    tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
        kotlinOptions {
            // Treat all Kotlin warnings as errors
            //useIR = true

            //allWarningsAsErrors = true

            freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn"

            // Enable experimental coroutines APIs, including Flow
            freeCompilerArgs += "-Xopt-in=kotlinx.coroutines.ExperimentalCoroutinesApi"
            freeCompilerArgs += "-Xopt-in=kotlinx.coroutines.FlowPreview"
            freeCompilerArgs += "-Xopt-in=kotlin.Experimental"
            freeCompilerArgs += "-Xallow-jvm-ir-dependencies"

            // Set JVM target to 1.8
            jvmTarget = "1.8"
        }
    }
}
buildscript{
存储库{
谷歌()
mavenCentral()
maven(url=”https://jitpack.io")
maven(url=”https://repo1.maven.org/maven2/")
maven(url=”https://plugins.gradle.org/m2/")
maven(url=”https://github.com/userxpro/userx/raw/maven/")
maven(url=”https://dl.bintray.com/kotlin/kotlin-eap/")
maven(url=”https://dl.bintray.com/kotlin/kotlinx/")
maven(url=”https://kotlin.bintray.com/kotlinx")
maven(url=”https://oss.sonatype.org/content/repositories/snapshots")
maven(url=”http://storage.googleapis.com/r8-releases/raw")
gradlePluginPortal()
}
依赖关系{
类路径(libs.r8)
类路径(libs.androidGradlePlugin)
类路径(libs.kotlin.gradlePlugin)
类路径(libs.hilt.gradlePlugin)
classpath(“com.google.gms:googleservices:4.3.4”)
类路径(“com.google.firebase:firebase crashlytics gradle:2.4.1”)
classpath(“com.google.firebase:perf plugin:1.3.4”)
}
}
子项目{
存储库{
谷歌()
mavenCentral()
maven(url=”https://jitpack.io")
maven(url=”https://repo1.maven.org/maven2/")
maven(url=”https://plugins.gradle.org/m2/")
maven(url=”https://dl.bintray.com/kotlin/kotlin-eap/")
maven(url=”https://dl.bintray.com/kotlin/kotlinx/")
maven(url=”https://kotlin.bintray.com/kotlinx")
maven(url=”https://oss.sonatype.org/content/repositories/snapshots")
maven(url=”https://github.com/userxpro/userx/raw/maven/")
jcenter()
}
tasks.withType{
科特洛普斯酒店{
//将所有Kotlin警告视为错误
//useIR=true
//ALLWARNINGASERRORS=真
freeCompilerArgs+=“-Xopt in=kotlin.requireResoptin”
//启用实验性协同路由API,包括流
freeCompilerArgs+=“-Xopt in=kotlinx.coroutines.ExperimentalRoutineSAPI”
freeCompilerArgs+=“-Xopt in=kotlinx.coroutines.FlowPreview”
freeCompilerArgs+=“-Xopt in=kotlin.Experimental”
freeCompilerArgs+=“-Xallow jvm ir依赖项”
//将JVM目标设置为1.8
jvmTarget=“1.8”
}
}
}
删除
id(“dagger.hilt.android.plugin”)

同步梯度


id(“dagger.hilt.android.plugin”)

顺便说一句,该插件在其他模块中工作