找不到ID为“ com.google.gms:google-services”的插件。扑

时间:2019-03-22 05:37:30

标签: android flutter flutter-dependencies

我是Flutter框架的新手。我试图在扑扑中安装Cloud Firestore,但遇到了问题。下面是我的代码和gradle文件: Android / build.gradlew:

buildscript {
    // ext.kotlin_version = '1.2.31'
    repositories {
        google()
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath 'com.google.gms:google-services:3.2.0'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

App / build.gradle是:

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 GradleException("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'
}

apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 28

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.barcode_app"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
apply plugin: 'com.google.gms:google-services'

运行flutter运行-v或在android中构建它后,出现错误: '错误:找不到ID为'com.google.gms:google-services'的插件。 enter image description here

我试图在stackoverflow和github上提供几乎所有可用的解决方案,但是问题仍然存在。

3 个答案:

答案 0 :(得分:4)

在您的app / build.gradle文件的底部,您拥有:

apply plugin: 'com.google.gms:google-services'

这实际上应该是:

apply plugin: 'com.google.gms.google-services'

请注意gmsgoogle-services之间的时间段,而不是冒号。

编辑:您可能会遇到此问题,因为Google自己的文档(最新编辑于3月20日)不正确。我已向他们发送了反馈,以纠正此问题。 Picture of typo in google doc  存档在这里http://archive.is/4Ujuc

答案 1 :(得分:0)

如果应用 Jmorris 和 Johnhunter 解决方案后问题仍然存在,请检查此solution

解决方案是:

Upgrade the Android Gradle plugin to 3.5.0
Upgrade the Google Services plugin to 4.3.3
Upgrade Gradle to 5.4.1 (the required Gradle version for this Android Gradle plugin version)

答案 2 :(得分:0)

只需删除 #include<fplus/maps.hpp> // ... int main() { map<string, int32_t> myMap{{"a", 1}, {"b", 2}}; vector<string> keys = fplus::get_map_keys(myMap); // ... return 0; } 文件并使用您的项目重新配置 Firebase。