gpt4 book ai didi

android - 已应用 Hilt Android Gradle 插件但没有 com.google.dagger :hilt-android dependency was found

转载 作者:行者123 更新时间:2023-12-03 16:47:12 29 4
gpt4 key购买 nike

我收到这个 gradle 同步错误 - 应用了 Hilt Android Gradle 插件,但未找到 com.google.dagger:hilt-android 依赖项。 有人可以帮忙吗? :)
我正在使用 kotlin dsl,我在 buildSrc 中有 libs.kt
buildSrc - build.gradle.kts:

plugins {
`kotlin-dsl`
}

repositories {
jcenter()
}
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:
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"
}
}
}

最佳答案

消除id("dagger.hilt.android.plugin")同步梯度
添加id("dagger.hilt.android.plugin")

关于android - 已应用 Hilt Android Gradle 插件但没有 com.google.dagger :hilt-android dependency was found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65303346/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com