Android studio Bumblebee build.gradle 根项目无法添加类路径依赖项
Android studio Bumblebee build.gradle root project can't add classpath dependencies
我正在尝试在我的新项目中实现匕首柄,但我发现新 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
}
当我尝试使用类路径实现刀柄和依赖块时,它告诉我:
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{} 块添加到 buildScript 块中解决:
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 中的依赖项问题 **。
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
id 'com.google.firebase.crashlytics'
}
dependencies {
implementation platform('com.google.firebase:firebase-bom:29.1.0')
implementation 'com.google.firebase:firebase-crashlytics'
implementation 'com.google.firebase:firebase-analytics'
}
解决项目级别的依赖关系问题,包括插件块上方的构建脚本
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
我正在尝试在我的新项目中实现匕首柄,但我发现新 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
}
当我尝试使用类路径实现刀柄和依赖块时,它告诉我:
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{} 块添加到 buildScript 块中解决:
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 中的依赖项问题 **。
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
id 'com.google.firebase.crashlytics'
}
dependencies {
implementation platform('com.google.firebase:firebase-bom:29.1.0')
implementation 'com.google.firebase:firebase-crashlytics'
implementation 'com.google.firebase:firebase-analytics'
}
解决项目级别的依赖关系问题,包括插件块上方的构建脚本
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}