Gradle 错误:找不到插件“com.google.gms.google-services”版本 4.4.0

问题描述 投票:0回答:1

我的 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(模块:应用程序) **

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 在以下任何来源中均未找到,并尝试了其中提到的解决方案。不幸的是,这些步骤都没有解决问题。

问题:

有人遇到过这个具体问题并找到解决方案吗?我正在寻找任何可以采取的见解或其他步骤来解决此错误。

android firebase gradle android-gradle-plugin build-error
1个回答
0
投票

始终建议使用所有库的最新版本。据我所知,就 Google Services Gradle 插件而言,最新版本目前是 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.2'
        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.application' version "${gradle_version}" apply false
    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.2

© www.soinside.com 2019 - 2024. All rights reserved.