Flutter集成Firebase时提示找不到com.google.gms.google-services插件
Flutter集成Firebase报错:Plugin [id: 'com.google.gms.google-services', version: '4.3.15', apply: false] was not found
我已经在StackOverflow上搜索并尝试了类似问题的解决方案,但在Flutter应用中集成Firebase时仍报错:Plugin [id: 'com.google.gms.google-services', version: '4.3.15', apply: false] was not found。
我的项目根目录build.gradle(android)内容如下:
buildscript { ext.kotlin_version = '1.9.0' repositories { google() mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:7.3.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath 'com.google.gms:google-services:4.3.15' } } plugins { // Add the dependency for the Google services Gradle plugin id 'com.google.gms.google-services' version '4.3.15' apply false } allprojects { repositories { google() mavenCentral() } } rootProject.buildDir = '../build' subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" project.evaluationDependsOn(':app') } tasks.register("clean", Delete) { delete rootProject.buildDir }
app模块下的build.gradle(app)内容如下:
def localProperties = new Properties() def localPropertiesFile = rootProject.file('local.properties') if (localPropertiesFile.exists()) { localPropertiesFile.withReader('UTF-8') { reader -> localProperties.load(reader) } } def flutterRoot = localProperties.getProperty('flutter.sdk') if (flutterRoot == null) { throw new Exception("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") } def flutterVersionCode = localProperties.getProperty('flutter.versionCode') if (flutterVersionCode == null) { flutterVersionCode = '1' } def flutterVersionName = localProperties.getProperty('flutter.versionName') if (flutterVersionName == null) { flutterVersionName = '1.0' } def flutterMinSDk = localProperties.getProperty('flutter.minSdkVersion')?.toInteger() if (flutterMinSDk == null) { flutterMinSDk = 30 } apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" apply plugin: 'com.google.gms.google-services' classpath 'com.google.gms:google-services:4.3.15' android { compileSdkVersion flutter.compileSdkVersion ndkVersion flutter.ndkVersion compileOptions { // add this line to support Java8 features coreLibraryDesugaringEnabled true sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } kotlinOptions { jvmTarget = '1.8' } sourceSets { main.java.srcDirs += 'src/main/kotlin' } defaultConfig { applicationId "com.example.SApp" minSdkVersion flutterMinSDk targetSdkVersion flutter.targetSdkVersion versionCode flutterVersionCode.toInteger() versionName flutterVersionName multiDexEnabled true } buildTypes { release { signingConfig signingConfigs.debug } } } flutter { source '../..' } plugins { id 'com.android.application' } dependencies { // add this line to support Java8 features coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5' implementation 'androidx.multidex:multidex:2.0.1' implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'com.google.firebase:firebase-messaging:23.2.1' }
我已通过CLI添加Firebase文件,google-services.json已放置在app文件夹中,恳请提供帮助。
内容的提问来源于stack exchange,提问作者VerySeriouslyCurious
相关产品推荐
相关产品推荐

