Gradle错误:Plugin 'com.google.gms.google-services' Version 4.4.0 Not Found

dtcbnfnu  于 2023-11-18  发布在  Go
关注(0)|答案(1)|浏览(342)

我的Gradle构建版本遇到问题,出现与Google Services Plugin相关的错误。错误消息如下:

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(Project:example)

// 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(Module: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:Plugin com.google.gms.google-services version 4.4.0 apply: false was not found in any of the following sources上遇到了类似的问题,并尝试了那里提到的解决方案。不幸的是,这些步骤都没有解决这个问题。
问:
是否有人遇到此特定问题并找到了解决方案?我正在寻找任何见解或其他步骤,我可以采取解决此错误。

byqmnocz

byqmnocz1#

它总是建议使用所有库的最新版本.据我所知,在谷歌服务Gradle插件的情况下,latest version is currently 5.0.0.
我亲自尝试过,但由于以下错误,我无法使其工作:
未在以下源中找到插件[id:'com.google.gms. google-services',版本:'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版本1.9.10和Gradle版本8.1.3

相关问题