当我读到这个doc:https://developers.google.com/android/guides/google-services-plugin时,他们说:
作为在安卓应用程序中启用Google或Firebase服务的一部分,您可能必须将google插件添加到build.gradle文件中:
依赖关系{ classpath‘com.google.gms:google:4.3.14’// .}
然后他们还说:
为您启用的服务所需的基本库添加依赖项。此步骤要求您在应用程序/build.gradle文件中应用Gradle插件,如: apply plugin:'com.google.gms.google- Services‘
因此,我在android的最后一个版本中启动了一个空白的新安卓项目,并为根build.gradle提供了如下内容:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.3.1' apply false
id 'com.android.library' version '7.3.1' apply false
}
在app/build.gradle中:
plugins {
id 'com.android.application'
}
android {
namespace 'app.dependencieswalker'
compileSdk 32
defaultConfig {
applicationId "app.dependencieswalker"
minSdk 21
targetSdk 32
versionCode 1
versionName "1.0"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation "com.alcinoe:alcinoe-firebase:1.0.0"
}
所以我必须在其中添加
dependencies {
classpath 'com.google.gms:google-services:4.3.14'
// ...
}
和
apply plugin: 'com.google.gms.google-services' ?
发布于 2022-11-23 16:33:35
在根 build.gradle
文件中的plugins
块中添加
plugins {
//....
id 'com.google.gms.google-services' version '4.3.14' apply false
}
然后将其应用于模块build.gradle
文件中:
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
}
发布于 2022-11-23 15:50:48
您应该按以下方式修改根build.gradle:
plugins {
id 'com.android.application' version '7.3.1' apply false
id 'com.android.library' version '7.3.1' apply false
}
buildscript {
repositories {
mavenCentral()
google()
}
dependencies {
classpath 'com.google.gms:google-services:4.3.10'
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
和应用程序/build.gradle
plugins {
id 'com.android.application'
id 'com.google.gms.google-services' version '4.3.14' apply true
}
android {
namespace 'app.dependencieswalker'
compileSdk 32
defaultConfig {
applicationId "app.dependencieswalker"
minSdk 21
targetSdk 32
versionCode 1
versionName "1.0"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation "com.alcinoe:alcinoe-firebase:1.0.0"
}
https://stackoverflow.com/questions/74549113
复制相似问题