- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我收到这个 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/
Dagger 和 Dagger 2.0 有什么区别,为什么 Google 决定 fork 现有项目? 最佳答案 来自 Dagger 2 presentation 的一些引述 Dagger 1 的问题:
我想制作一个包含一个主要 Activity 和多个 fragment 的简单项目。在这里,我在一项 Activity 中有两个 fragment ,我想将演示者注入(inject)登录 fragmen
我是 dagger 的新手,我正在寻找如何在 dagger-2.x 中实现 spring 配置文件等功能。我想为我的开发环境和生产环境使用不同的 bean,但我使用的是带有 Java 的 Dagger
假设我有两个服务 AService 和 BService,它们都需要一个 API key 。 所以在我的模块中,我不能做类似的事情: @Provides @Singleton @A @ApiKey S
我对 Dagger 很陌生——我什至不知道它是否适用于我的应用程序 我有一个搜索页面,它返回有关给定名人的最新消息。 我写了一个测试来验证当我们搜索一个受欢迎的名人时结果会出现在页面上。 page有一
我最近将 dagger 2.8 更新为 2.9 dagger。和最新版本的文档已添加如下: -添加@BindsInstance组件构建器可以轻松绑定(bind)在图之外构建的实例。 -制作人:已添加
Dagger documentation页面说: To get the most out of compile-time validation, create a module that includ
我可以知道之间的区别吗? @Singleton VS 静态 在dagger2中提供? @Provides static User currentUser(AuthManager authManager
我有一个功能,我需要为不同的用户提供不同的房间数据库。 我正在使用 Dagger 2 创建房间数据库。我的应用程序组件创建一个房间数据库。当用户切换到另一个用户时,我想为此创建新的房间数据库,我需要创
我是 Dagger 2 的新手,正在尝试 IntelliJ 中的 Dagger 2 Coffee Example,它似乎不会生成 DaggerCoffeeApp_Coffee(它应该生成它),即使我密
我正在尝试在 Android 上使用 Dagger 2。我以前让它工作,我有一个 appModule 将依赖项注入(inject)应用程序中的特定类。我的问题是我收到错误 Error:(14, 55)
我是 kotlin 和 Dagger 的新手。我有一个小问题,我不知道如何解决,也没有找到解决方案。 这就是我所拥有的: @Module class AppModule (app: Applicati
我正在尝试使用 Dagger 建立一个项目。现在,当我构建时,没有为组件生成任何 Dagger* 类,并且出现以下错误: Error:(10, 8) error: [com.redditapp.dag
在 Dagger 中,我有时会看到有些组件只扩展一个接口(interface),而其他组件则使用 dependencies。 例如我们有一个基础组件: @Singleton @Component(mo
有没有办法告诉 Dagger 2 如何提供一些东西,但不允许它被注入(inject)? 假设我要注入(inject)一个 Qux .一个 Qux需要 Foo和 Bar : @Provides @Sin
( x-post from /r/androiddev ) 我只想在序言中说这不是一篇“哪个更好”的帖子;这严格来说是一个关于如何使用 Dagger 构建某些东西的问题(以及如何在 Kodein 中构
https://developer.android.com/topic/libraries/architecture/ 在Android架构蓝图中,为什么dagger是基于mvp架构而不是MVVM架构
我第一次开始同时使用 Kotlin 和 Dagger 2。我假设一切都与 Java 中的相同,但显然不完全相同。 Dagger 不会为我生成 Dagger* 文件。这是我的代码: 组件: @PerAc
我正在尝试将 Dagger 2 与 eclipse 集成,我使用的库如下: dagger-2.0.jar dagger-compiler-2.0.jar guava-13.0.1.jar javawr
我想练习这个Dagger 2 Vehicle Motor例子。 除了我的 gradel.build 之外,我所做的一切都与该教程中的一样: compile 'com.google.dagger:dag
我是一名优秀的程序员,十分优秀!