尝试将 Firebase 添加到我的 android 项目时,出现 gradle 同步错误 JAVA_LETTER_OR_DIGIT

Him*_*nee 4 android android-gradle-plugin firebase-realtime-database

当我按照 firebase 指南中的说明添加依赖项并同步项目时,我收到错误 JAVA__LETTER_OR_DIGIT 。我使用 MAC OS X Yosemite 并且我的 android studio 版本是 3.1.4

我的应用等级文件

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "e.apple.mse_project"
        minSdkVersion 22
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.google.firebase:firebase-analytics:17.2.0'
    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'
Run Code Online (Sandbox Code Playgroud)

我的项目成绩文件

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.4'
        classpath 'com.google.gms:google-services:4.3.2'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)

这是我在构建控制台中得到 的错误在我的构建控制台中显示的错误日志

提前致谢 !

dez*_*hik 6

问题在于 Android gradle 插件与 Google 的 Maven 存储库不能很好地配合使用。

正如@mownathi-manigundan 所说,您可以将您的 google-services 降级到 4.2.0。版本 4.2.0 在 AndroidTools Repository 中可用,过时的 gradle 插件处理得很好

但是最好将您的插件更新到 3.2 或更高版本并使用推荐的 com.google.gms:google-services:4.3.2。您可以在此处阅读更多信息