Missing api_key/current key with Google Services 3.0.0

后端 未结 17 868
小鲜肉
小鲜肉 2020-12-02 07:20

Since I upgraded the project with the latest version of google services and libraries (9.0.0), I have this strange issue :

Grade console :

:         


        
相关标签:
17条回答
  • 2020-12-02 07:46

    Adding empty current key value in google-services.json file solved this problem for me

    "api_key": [{ "current_key": "" }]

    0 讨论(0)
  • 2020-12-02 07:46

    Click on Overview -> Gear icon -> Project settings.

    Go to Download latest config and Click on google-service.json button to download file and save it to app folder and Compile again. Enjoy!

    0 讨论(0)
  • 2020-12-02 07:47

    Yes, as for the first time using with Firebase, i face like that.Click on your app menu and click "Manage".

    you can download google-services.json again.

    0 讨论(0)
  • 2020-12-02 07:48

    Generate new config file (google-services.json) from: https://developers.google.com/cloud-messaging/android/client#get-config

    Newly config file with "api_key": [ { "current_key": XXX } ] in client section

    Update: or manually enabled service in developer console and generate key.

    0 讨论(0)
  • 2020-12-02 07:48

    First in your JSON file

    Replace

    "api_key": []
    

    with

    "api_key": [{ "current_key": "" }]
    

    Then the gradle build will be successful but when you run your application you may get errors like the following..

    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/LICENSE
        File1: C:\Users\bucky\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-core\2.2.2\d20be6a5ffffd6f8cfd36ebf6dea329873a1c41f1b\jackson-core-2.2.2.jar
        File2: C:\Users\bucky\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-databind\2.2.2\3c8f6018eaa72d43b261181e801e6f8676c16ef6\jackson-databind-2.2.2.jar
        File3: C:\Users\bucky\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-annotations\2.2.2\285cb9c666f0f0f3dd8a1be04e1f457eb7b15113\jackson-annotations-2.2.2.jar
    

    To fix this issue you can add the following to your app.gradle file.. It worked for me.

    packagingOptions {
            exclude 'META-INF/DEPENDENCIES'
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/LICENSE.txt'
            exclude 'META-INF/license.txt'
            exclude 'META-INF/NOTICE'
            exclude 'META-INF/NOTICE.txt'
            exclude 'META-INF/notice.txt'
            exclude 'META-INF/ASL2.0'
        }
    

    Edit: It showed me some error later while building the apk file. So I had to download the json file again. After 2 trial I got the json file with a valid api key.

    0 讨论(0)
  • 2020-12-02 07:49

    add this into your google-service.json file . you will find it under app/google-service.json

    "api_key": [ { "current_key": " your-google-api-key" }]

    0 讨论(0)
提交回复
热议问题