提问人:D_Dyson 提问时间:11/15/2023 最后编辑:Alex MamoD_Dyson 更新时间:11/16/2023 访问量:75
Gradle 错误:未找到插件“com.google.gms.google-services”版本 4.4.0
Gradle Error: Plugin 'com.google.gms.google-services' Version 4.4.0 Not Found
问:
我的 Gradle 版本遇到了一个问题,我收到了与 Google 服务插件相关的错误。错误消息如下:
Plugin [id: 'com.google.gms.google-services', version: '4.4.0', apply: false] was not found in any of the following sources:
我尝试过什么:
1.) 我已经确保我的 build.gradle 文件设置正确(根据 firebase 说明)。下面是一个供参考的片段:
build.gradle (项目:示例) **
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '8.1.0' apply false
id 'org.jetbrains.kotlin.android' version '1.8.10' apply false
id 'com.google.gms.google-services' version '4.4.0' apply false
}
build.gradle (模块:app) **
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'com.google.gms.google-services'
}
android {
namespace 'com.example.example'
compileSdk 33
defaultConfig {
applicationId "com.example.example"
minSdk 28
targetSdk 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary true
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion '1.4.3'
}
packaging {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
}
dependencies {
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1'
implementation 'androidx.activity:activity-compose:1.7.2'
implementation platform('androidx.compose:compose-bom:2023.03.00')
implementation 'androidx.compose.ui:ui'
implementation 'androidx.compose.ui:ui-graphics'
implementation 'androidx.compose.ui:ui-tooling-preview'
implementation 'androidx.compose.material3:material3'
implementation 'androidx.core:core-ktx:1.10.1'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.9.0'
androidTestImplementation platform('androidx.compose:compose-bom:2023.03.00')
androidTestImplementation 'androidx.compose.ui:ui-test-junit4'
debugImplementation 'androidx.compose.ui:ui-tooling'
debugImplementation 'androidx.compose.ui:ui-test-manifest'
implementation 'com.google.mlkit:text-recognition:16.0.0'
implementation 'com.google.mlkit:text-recognition-chinese:16.0.0'
implementation 'com.google.mlkit:text-recognition-devanagari:16.0.0'
implementation 'com.google.mlkit:text-recognition-japanese:16.0.0'
implementation 'com.google.mlkit:text-recognition-korean:16.0.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4'
implementation 'androidx.palette:palette:1.0.0'
implementation 'com.google.mlkit:translate:17.0.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation project(':opencv')
implementation platform('com.google.firebase:firebase-bom:32.5.0')
implementation 'com.google.firebase:firebase-analytics'
}
settings.gradle(项目设置) **
pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "example"
include ':app'
include ':opencv'
2.) 我在 Stack Overflow 上遇到了类似的问题:插件 com.google.gms.google-services 版本 4.4.0 apply: false 在以下任何来源中都找不到,并尝试了那里提到的解决方案。不幸的是,这些步骤都没有解决问题。
问题:
有没有人遇到过这个具体问题并找到了解决方案?我正在寻找可以采取的任何见解或其他步骤来解决此错误。
答:
0赞
Alex Mamo
11/16/2023
#1
始终建议使用所有库的最新版本。据我所知,就 Google Services Gradle 插件而言,最新版本目前是 5.0.0。
我亲自尝试过,但由于以下错误,我无法使其工作:
插件 [id: 'com.google.gms.google-services', version: '5.0.0', apply: false] 在以下任何来源中均未找到:
它与您的情况相同,但版本不同。但是,当我使用该版本时,一切都按预期工作。我将与您分享我的依赖项:4.4.0
build.gradle(项目文件):
buildscript {
ext {
gradle_version = '8.1.3'
kotlin_version = '1.9.10'
google_services_version = '4.4.0'
compose_bom_version = '2023.10.01'
compose_version = '1.5.3'
}
}
plugins {
id 'com.android.library' version "${gradle_version}" apply false
id 'org.jetbrains.kotlin.android' version "${kotlin_version}" apply false
id 'com.google.gms.google-services' version "${google_services_version}" apply false
}
build.gradle(模块文件):
plugins {
id "com.android.application"
id "kotlin-android"
id "kotlin-kapt"
id "com.google.gms.google-services"
id 'org.jetbrains.kotlin.android'
}
dependencies {
//Compose
implementation platform("androidx.compose:compose-bom:$compose_bom_version")
implementation "androidx.compose.material:material"
//...
}
所以就我而言,使用 Kotlin 版本和 Gradle 版本。1.9.10
8.1.3
评论
0赞
Alex Mamo
11/17/2023
嘿,你好。您是否尝试过上面的解决方案,它对您有用吗?
0赞
Alex Mamo
11/22/2023
嘿,你好。您是否尝试过上面的解决方案,它对您有用吗?
评论