I have a gradle sync error JAVA_LETTER_OR_DIGIT when trying to add Firebase to my android project

不打扰是莪最后的温柔 提交于 2019-12-24 01:09:55

问题


When I added the dependencies as told in the firebase guide and sync the project ,I get the error JAVA__LETTER_OR_DIGIT .I work with MAC OS X Yosemite and my android studio version is 3.1.4

My app grade file

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'

My project grade file

// 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
}

This is the error that I get in the build console The error log that shows in my build console

Thanks in advance !


回答1:


The problem is with Android gradle plugin which doesn't work well with Google's Maven repository.

You can downgrade your google-services down to 4.2.0 as it was said by @mownathi-manigundan. Version 4.2.0 is available in AndroidTools Repository which outdated gradle plugin handles just fine

But it'd be better to update your plugin up to 3.2 or higher and use recommended com.google.gms:google-services:4.3.2. You can read more here how to to this




回答2:


Try changing your version of gms google service in your project gradle as com.google.gms:google-services:4.2.0



来源:https://stackoverflow.com/questions/58102484/i-have-a-gradle-sync-error-java-letter-or-digit-when-trying-to-add-firebase-to-m

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!