文件 google-services.json 丢失。如果没有它,Google 服务插件就无法运行。(适用于 firebase ml 套件)

Sak*_*ain 5 android firebase android-studio firebase-mlkit

我见过一些与此错误相关的类似问题。但我没能解决这个问题。我正在使用 firebase ml 套件来识别图像中的文本。我已将 google-services.json 文件添加到应用程序目录中,但仍然遇到相同的错误。如果有人可以解决这个问题请告诉我。

我收到以下错误:

File google-services.json is missing. The Google Services Plugin cannot function without it. 
 Searched Location: 
E:\Practices\Android Projects\2019\DataFactor\app\src\nullnull\debug\google-services.json
E:\Practices\Android Projects\2019\DataFactor\app\src\debug\nullnull\google-services.json
E:\Practices\Android Projects\2019\DataFactor\app\src\nullnull\google-services.json
E:\Practices\Android Projects\2019\DataFactor\app\src\debug\google-services.json
E:\Practices\Android Projects\2019\DataFactor\app\src\nullnullDebug\google-services.json
E:\Practices\Android Projects\2019\DataFactor\app\google-services.json
Run Code Online (Sandbox Code Playgroud)

我的项目的 build.gradle :

buildscript {
    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.1'
        classpath 'com.google.gms:google-services:4.0.1'
        // 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)

我的应用程序的 build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "app.shakil.com.datafactor"
        minSdkVersion 19
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.+'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:design:27.+'
    implementation 'com.google.firebase:firebase-core:16.0.7'
    implementation 'com.google.firebase:firebase-ml-vision:19.0.2'
    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)

小智 0

这个问题由(我猜)原始海报回答:\n“是的,我找到了答案。我放错了 json 文件。尝试将 json 文件放在正确的目录中。我刚刚将 json 文件从项目级别移动到应用程序\xe2\x80\x93 Sakhawat Hossain 2019 年 10 月 22 日 9:30"。

\n