Failed to sync project with apply plugin: 'com.google.gms.google-services'

2,529 views
Skip to first unread message

Marcos Nobre

unread,
May 23, 2016, 9:30:51 AM5/23/16
to Firebase Google Group
Hi there,

Has anyone had this problem when migrating to the new Firebase version?

Error:Unable to load class 'com.google.gson.JsonObject'.
Possible causes for this unexpected error include:<ul><li>Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
<a href="syncProject">Re-download dependencies and sync project (requires network)</a></li><li>The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
<a href="stopGradleDaemons">Stop Gradle build processes (requires restart)</a></li><li>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.</li></ul>In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

I have done all recommendations and commented all dependencies but the problem remains. Gradle only syncs successfully when I remove apply plugin: 'com.google.gms.google-services'


Many thanks,
Marcos

János Szidor

unread,
May 30, 2016, 11:02:45 AM5/30/16
to Firebase Google Group
I also have this problem. The same exact problem. Could you somehow manage to solve it?

Tom Redman

unread,
Jun 7, 2016, 3:22:12 PM6/7/16
to Firebase Google Group
Same here. Any luck?

János Szidor

unread,
Jun 7, 2016, 5:03:09 PM6/7/16
to Firebase Google Group
For me the solution was to put "apply plugin: 'com.google.gms.google-services'" to the end of the build.gradle file and to put  "compile 'com.google.firebase:firebase-messaging:x.x.x'" at the BEGINNING of dependencies in the file. Hope it helps.

Doug Stevenson

unread,
Jun 7, 2016, 5:04:55 PM6/7/16
to Firebase Google Group
There's a few things I can think of to try based on the error messages.  These errors are new to me, so I'm just throwing a bunch of things out there:

If you are building with Android Studio, could you also try the command line (e.g. ./gradlew assembleDebug) to see if there is any difference?

Also check the version of gradle you're using.  The latest is 2.13, which has been working great for me.  You can change the version in your project root under gradle/wrapper/gradle-wrapper.properties.  You can just change the version right there in distributionUrl.

The error messages are suggesting that something unexpected happened while downloading dependencies needed for the build.  If you're able to "reset" gradle, it might be able to recover by trying everything again.  The most straightforward thing to try might just be a reboot to get all the gradle daemon processes to die and restart.  If that doesn't work, you might have to try something like blowing away some internal caches.  Try removing these directories: 

~/.gradle/caches (Gradle internal stuff)
~/.m2 (your Maven local cache where gradle stores the dependencies it downloads)

If you remove these directories, expect that your next build will take time to download some dependencies again.

Doug
Reply all
Reply to author
Forward
0 new messages