簡體   English   中英

Firebase:google-services.json 錯誤

[英]Firebase: google-services.json error

這是我第一次使用 Firebase,我已經完成了 Firebase 為 android 提供的視頻和文檔中的每一步,但是我在運行我的項目時遇到了這個錯誤。

Information:Gradle tasks [:app:assembleDebug]
Could not find google-services.json while looking in [src/nullnull/debug,       src/debug/nullnull, src/nullnull, src/debug, src/nullnullDebug]
Could not find google-services.json while looking in [src/nullnull/release, src/release/nullnull, src/nullnull, src/release, src/nullnullRelease]
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAnimatedVectorDrawable2421Library UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72421Library UP-TO-DATE
:app:prepareComAndroidSupportSupportCompat2520Library UP-TO-DATE
:app:prepareComAndroidSupportSupportCoreUi2520Library UP-TO-DATE
:app:prepareComAndroidSupportSupportCoreUtils2520Library UP-TO-DATE
:app:prepareComAndroidSupportSupportFragment2520Library UP-TO-DATE
:app:prepareComAndroidSupportSupportMediaCompat2520Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42520Library UP-TO-DATE
:app:prepareComAndroidSupportSupportVectorDrawable2421Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesBasement1180Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesBasementLicense1180Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesTasks1180Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesTasksLicense1180Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseAnalytics1180Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseAnalyticsImpl1180Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseAnalyticsImplLicense1180Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseAnalyticsLicense1180Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseCommon1180Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseCommonLicense1180Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseCore1180Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseFirestore1180Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseIid1180Library UP-TO-DATE
:app:prepareComGoogleFirebaseFirebaseIidLicense1180Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:mergeDebugShaders UP-TO-DATE
:app:compileDebugShaders UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:processDebugGoogleServices
Parsing json file: C:\Users\myPc\AndroidStudioProjects\Try\app\google-services.json
:app:generateDebugResources
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:incrementalDebugJavaCompilationSafeguard
:app:compileDebugJavaWithJavac
:app:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources
:app:prePackageMarkerForDebug
:app:transformClassesWithDexForDebug
To run dex in process, the Gradle daemon needs a larger heap.
It currently has approximately 910 MB.
For faster builds, increase the maximum heap size for the Gradle daemon to more than 2048 MB.
To do this set org.gradle.jvmargs=-Xmx2048M in the project gradle.properties.
For more information see https://docs.gradle.org/current/userguide/build_environment.html
:app:mergeDebugJniLibFolders UP-TO-DATE
:app:transformNative_libsWithMergeJniLibsForDebug UP-TO-DATE
:app:processDebugJavaRes UP-TO-DATE
:app:transformResourcesWithMergeJavaResForDebug FAILED
Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
com.android.build.api.transform.TransformException:         com.android.builder.packaging.DuplicateFileException: Duplicate files copied in     APK META-INF/maven/com.squareup.okhttp/okhttp/pom.xml
File1: C:\Users\myPc\.gradle\caches\modules-2\files-    2.1\com.squareup.okhttp\okhttp\2.7.2\20f6463eb19ac61960c5d91a094c2f4f0727dc2e\okhttp-2.7.2.jar
File2: C:\Users\myPc\AndroidStudioProjects\Try\app\build\intermediates\exploded-aar\com.google.firebase\firebase-firestore\11.8.0\jars\classes.jar
Information:BUILD FAILED
Information:Total time: 1 mins 1.894 secs
Information:1 error
Information:0 warnings
Information:See complete output in console

我添加了所需的路徑和依賴項:

這是我的 build.gradle(project:Try)

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


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

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

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

這是我的 build.gradle(Module:app)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "25.0.3"

    defaultConfig {
        applicationId "com.salmasamy.trytrytry"
        minSdkVersion 19
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.google.firebase:firebase-core:11.8.0'
    compile 'com.google.firebase:firebase-firestore:11.8.0'

}

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

我還在project->app文件夾中添加了google-services.json文件,並確保沒有多余的空格,並且我有正確版本的 google play 服務和 google 存儲庫。

當我構建項目時一切正常,但只有在我運行它時才會得到這個。

因為你應該使用 gradle 3.+

buildscript {

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

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

}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM