Skip to main content

Error:Execution failed for task ':app:processDebugGoogleServices'. > Missing api_key/current_key object

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\d20be6a5ddd6f8cfd36ebf6dea329873a1c41f1b\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.

Comments

Popular posts from this blog

org.gradle.api.internal.tasks.DefaultTaskInputs$TaskInputUnionFileCollection cannot be cast to org.gradle.api.internal.file.collections.

Error:Cause: org.gradle.api.internal.tasks.DefaultTaskInputs$TaskInputUnionFileCollection cannot be cast to org.gradle.api.internal.file.collections.DefaultConfigurableFileCollection Possible causes for this unexpected error include: Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.) Re-download dependencies and sync project (requires network) The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem. Stop Gradle build processes (requires restart) Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project. In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes. Solutions: Upgrade your gradle build tools to the latest version. One easy way to do this is to add the latest version of the build tools as a depend...

How To Reduce APK File Size in Android Studio

Your APK can contain content that users download but never use, like regional or language information. To create a minimal download for your users, you can segment your app into several APKs, differentiated by factors such as screen size or GPU texture support. Here are Some ways to Reduce Apk File size: Use  ProGaurd Remove any debug info  you have in the app ( statements such as Log.i()). They can be wrapped in a condition which is only enabled while testing out the application. Use  recommended media formats Image: PNG,JPG & WebP Audio: AAC Video: H264 AVC Compress images  using OptiPNG or PNGCrush Use 9patch to  scale images Find unused resources  and  remove them . Refrain using multiple resources to achieve the same functionality . The resources is not limited to images but can be extended to APIs. Sometimes, using a singular API which provide multiple results is more efficient than using two or th...