gpt4 book ai didi

Android studio Bumblebee build.gradle 根项目无法添加类路径依赖

转载 作者:行者123 更新时间:2023-12-04 23:39:24 28 4
gpt4 key购买 nike

我正在尝试在我的新项目中实现 dagger-hilt,但我发现新的 Android Studio 版本(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 和依赖 block 时,它告诉我:
 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.
}

最佳答案

通过将 dependencies{} block 添加到 buildScript block 中解决:

buildscript {
ext {
compose_version = '1.0.5'
hilt_version = '2.40.5'
}

dependencies {
classpath 'com.google.dagger:hilt-android-gradle-plugin:2.40.5'
classpath 'com.google.gms:google-services:4.3.10'
}
}// 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

}
task clean(type: Delete) {
delete rootProject.buildDir
}

关于Android studio Bumblebee build.gradle 根项目无法添加类路径依赖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70910759/

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