admin管理员组

文章数量:1122832

FAILURE: Build failed with an exception.

  • Where: Build file 'C:\Users\ASUS\Documents\fyp\android\build.gradle' line: 7

  • What went wrong: A problem occurred evaluating root project 'android'.

Could not find method classpath() for arguments [com.google.gms:google-services:4.4.1] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

android/build.gradle

android/app/build.gradle

FAILURE: Build failed with an exception.

  • Where: Build file 'C:\Users\ASUS\Documents\fyp\android\build.gradle' line: 7

  • What went wrong: A problem occurred evaluating root project 'android'.

Could not find method classpath() for arguments [com.google.gms:google-services:4.4.1] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

android/build.gradle

android/app/build.gradle

Share Improve this question asked yesterday qadri Waieqadri Waie 211 bronze badge 1
  • On Stack Overflow, please don't show pictures of text and code. Copy the text into the question itself and format it so that it's easy to read, copy, and search. You can edit the question to correct this using the edit link at the bottom. – Doug Stevenson Commented yesterday
Add a comment  | 

2 Answers 2

Reset to default 0

You can add your compatible version of this codes to the top of android/build.gradle file. Mine is working like that.

buildscript {
    dependencies {
        classpath 'com.android.tools.build:gradle:8.1.0'
        classpath 'com.google.gms:google-services:4.4.2'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:3.0.2'
    }
}

plugins{
    id "com.google.gms.google-services" version '4.4.2' apply false
    id ("com.google.firebase.crashlytics") version '3.0.2' apply false
}

also settings.gradle is like that

pluginManagement {
    def flutterSdkPath = {
        def properties = new Properties()
        file("local.properties").withInputStream { properties.load(it) }
        def flutterSdkPath = properties.getProperty("flutter.sdk")
        assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
        return flutterSdkPath
    }()

    includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")

    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
    }
}

plugins {
    id "dev.flutter.flutter-plugin-loader" version "1.0.0"
    id "com.android.application" version "8.1.0" apply false
    id "org.jetbrains.kotlin.android" version "1.8.22" apply false
    id 'com.google.gms.google-services' version '4.4.2' apply false
}

include ":app"

You mix imperative and declarative to apply gradle plugin.

Please follow this guide and ensure there is no more mixing: https://docs.flutter.dev/release/breaking-changes/flutter-gradle-plugin-apply

And to apply correctly the gms plugin:

Remove dependencies section from your android/build.gradle

android/settings.gradle

plugins {
// ...
id "com.google.gms.google-services" version "4.3.15" apply false
}

android/app/build.gradle

plugins {
  // ...
  id 'com.google.gms.google-services'
}

You can find the complete migration here: https://docs.flutter.dev/release/breaking-changes/flutter-gradle-plugin-apply#google-mobile-services-and-crashlytics

本文标签: androidcomgooglegmsgoogleservices441 problem how to solveStack Overflow