[Unity] google-services.json file exists in Assets folder but there is an error that it's missing during gradle build

2,869 views
Skip to first unread message

Mina Marković

unread,
Sep 13, 2018, 10:56:55 AM9/13/18
to Firebase Google Group
I am using Unity 2017.3.0f3

Adding Firebase Messaging to my project


Downloaded from Firebase console and included google-services.json file to Assets folder!

Modifed gradle file according to: https://firebase.google.com/docs/android/setup

But build fails with the error:

    [09:33:15][Create APK] FAILURE: Build failed with an exception.
    [09:33:15][Create APK] 
    [09:33:15][Create APK] * What went wrong:
    [09:33:15][Create APK] Execution failed for task ':processReleaseGoogleServices'.
    [09:33:15][Create APK] > File google-services.json is missing. The Google Services Plugin cannot function without it. 
    [09:33:15][Create APK]    Searched Location: 
    [09:33:15][Create APK]   /Users/*******/Agents/Catwoman/work/c67e6b834a90eae8/Temp/gradleOut/src/nullnull/release/google-services.json
    [09:33:15][Create APK]   /Users/*******/Agents/Catwoman/work/c67e6b834a90eae8/Temp/gradleOut/src/release/nullnull/google-services.json
    [09:33:15][Create APK]   /Users/*******/Agents/Catwoman/work/c67e6b834a90eae8/Temp/gradleOut/src/nullnull/google-services.json
    [09:33:15][Create APK]   /Users/*******/Agents/Catwoman/work/c67e6b834a90eae8/Temp/gradleOut/src/release/google-services.json
    [09:33:15][Create APK]   /Users/*******/Agents/Catwoman/work/c67e6b834a90eae8/Temp/gradleOut/src/nullnullRelease/google-services.json
    [09:33:15][Create APK]   /Users/*******/Agents/Catwoman/work/c67e6b834a90eae8/Temp/gradleOut/google-services.json

I tried placing google-services.json to these locations:

myproject/Assets
myproject/Assets/Plugins/Android
myproject/Assets/Plugins/Android/src

Anyone with an idea what is wrong? THANKS! :)

My gradle file looks like this:

    buildscript {
repositories {
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'com.google.gms:google-services:4.1.0'
}
    }

    allprojects {
       repositories {
          flatDir {
            dirs 'libs'
          }
          google()
       }
    }

    apply plugin: 'com.android.application'

    android {
    compileSdkVersion 26
    buildToolsVersion '**BUILDTOOLS**'

defaultConfig {
targetSdkVersion 26
applicationId '**APPLICATIONID**'
multiDexEnabled true
}

lintOptions {
abortOnError false
}

aaptOptions {
noCompress '.unity3d', '.ress', '.resource', '.obb'**STREAMING_ASSETS**
}

    **SIGN**
buildTypes {
  debug {
  jniDebuggable true
  }
  release {
  minifyEnabled false
  **SIGNCONFIG**
  }
}

    }

    dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:multidex:1.0.1'
...
compile(name: 'com.google.android.gms.play-services-base-15.0.1', ext:'aar')
compile(name: 'com.google.android.gms.play-services-basement-15.0.1', ext:'aar')
compile(name: 'com.google.android.gms.play-services-ads-15.0.1', ext:'aar')
compile(name: 'com.google.android.gms.play-services-ads-identifier-15.0.1', ext:'aar')
compile(name: 'com.google.android.gms.play-services-tasks-15.0.1', ext:'aar')

compile(name: 'com.android.support.support-v4-26.1.0', ext:'aar')
compile(name: 'com.android.support.support-core-utils-26.1.0', ext:'aar')
compile(name: 'com.android.support.support-compat-26.1.0', ext:'aar')
compile(name: 'com.android.support.support-vector-drawable-26.1.0', ext:'aar')
compile(name: 'com.android.support.support-fragment-26.1.0', ext:'aar')

compile(name: 'com.google.firebase.firebase-common-16.0.2', ext:'aar')
compile(name: 'com.google.firebase.firebase-core-16.0.3', ext:'aar')
compile(name: 'com.google.firebase.firebase-messaging-17.3.1', ext:'aar')
compile(name: 'com.google.firebase.firebase-messaging-unity-5.2.1', ext:'aar')
compile(name: 'com.google.firebase.firebase-analytics-impl-16.2.1', ext:'aar')
compile(name: 'com.google.firebase.firebase-analytics-16.0.3', ext:'aar')
compile(name: 'com.google.firebase.firebase-app-unity-5.2.1', ext:'aar')
compile(name: 'com.google.firebase.firebase-iid-17.0.1', ext:'aar')
compile(name: 'com.google.firebase.firebase-iid-interop-16.0.0', ext:'aar')
compile(name: 'com.google.firebase.firebase-measurement-connector-17.0.0', ext:'aar')
compile(name: 'com.google.firebase.firebase-measurement-connector-impl-17.0.1', ext:'aar')

compile(name: 'com.google.games.gpgs-plugin-support-0.9.50', ext:'aar')
compile project(':fabric')
compile project(':unity-android-resources')
    }

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

Anthony Maurice

unread,
Sep 18, 2018, 4:17:23 PM9/18/18
to fireba...@googlegroups.com
Hi Mina,

You should be fine with having the google-services.json in myproject/Assets.  Normally you don't need to modify any gradle scripts when using Unity, unless you are using a more complex build system.  You should be able to just use Unity's "Build and Run" with Android selected, or do you need to use a gradle build for some reason?  If you do need to use a gradle build, you might need to copy the google-services.json directly into the output folder as a prerequisite, but again in normal cases you shouldn't need to touch gradle at all.

Have you tried getting one of our quickstarts set up?  https://github.com/firebase/quickstart-unity  They are fairly straightforward samples that you can just drop the unitypackage and google-services.json into to get going.

-Anthony

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/2a5e6cb3-523b-4e8d-a3bd-a6763499da08%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages