I have tried to search on stackoverflow and tried the solutions suggested in other stackoverflow questions of similar nature such as this and that but
I am still getting the following error Plugin [id: 'com.google.gms.google-services', version: '4.3.15', apply: false] was not found when i try to integrate firebase into my flutter app.
我试着在Stackoverflow上搜索,并尝试了其他类似性质的Stackoverflow问题中建议的解决方案,比如这个和那个,但我仍然得到以下错误插件[id:‘com.google.gms.google-services’,Version:‘4.3.15’,Apply:False]当我试图将Firebase集成到我的Ffltter应用程序中时,找不到。
My build.gradle(android) is as follows:
我的build.gradle(安卓)如下:
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
}
and my build.gradle(app) is as follows:
我的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'
}
I have also tried adding the firebase files using the cli via video
so the google-services.json is already in my app folder.
我也尝试过通过视频使用cli添加Firebase文件,所以google-services.json已经在我的应用程序文件夹中了。
Any help would be greatly appreciated. Thanks.
任何帮助都将不胜感激。谢谢。
更多回答
Why do you have classpath 'com.google.gms:google-services:4.3.15'
in app/build.gradle
? It only needs to be in the top level file.
为什么你的APP/build.gradle里有类路径‘com.google.gms:google-services:4.3.15’?它只需要在顶级文件中。
desperate measures. it was not there originally. but with or without it seems to still yields the same error
不顾一切的措施。它最初并不在那里。但不管有没有,似乎都会产生同样的错误
优秀答案推荐
remove This line from your projects
从您的项目中删除此行
plugins {
// Add the dependency for the Google services Gradle plugin
id 'com.google.gms.google-services' version '4.3.15' apply false
}
更多回答
我是一名优秀的程序员,十分优秀!