我尝试在我的新项目中实现dagger-hilt,但我发现新的Android工作室版本(Bumblebee 2021.1.1)中存在一些差异:
buildscript {
ext {
compose_version = '1.0.5'
hilt_version = '2.40.5'
}
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.1.0' apply false
id 'com.android.library' version '7.1.0' apply false
id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
}
dependencies {
classpath 'com.google.dagger:hilt-android-gradle-plugin:2.40.5'
}
task clean(type: Delete) {
delete rootProject.buildDir
}
当我尝试用类路径实现hilt和依赖块时,它告诉我:
Caused by: org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method classpath() for arguments [com.google.dagger:hilt-android-gradle-plugin:2.40.5] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
}
3条答案
按热度按时间ycggw6v21#
通过将depencies{}块添加到buildScript块中解决:
c90pui9n2#
解决了新android studio中应用级别的依赖性问题。
yzxexxkh3#
解决项目级别的依赖关系问题,包括插件块上方的生成脚本