简体   繁体   中英

Unable to load class 'com.google.gson.JsonObject'

I am trying to include firebase SDK in my Android Studio Project. But it giving me an error. I am using latest JDK version (1.7.0_71) and it is asking for upgrading higher version to (1.7.0_67).

I need help for basic firebase setup SDK on android. I tried to setup it by the reference of following link: https://firebase.google.com/docs/android/setup#add_the_sdk .

I am getting following error: Please check attached screenshot

截图

I had the same problem trying to GCM to an old android project. The solution for me was to also add

classpath 'com.android.tools.build:gradle:2.1.2'

to the top-level build file dependencies, just before classpath 'com.google.gms:google-services:3.0.0' . For the old android project, this dependency only existed in the module-level build file.

Make sure you are using Android Studio 1.5 or above. Just saw a guy who had the same issue and he was using android studio 1.0.1

Updating the Android Studio will fix it for you. Also check other pre-requisites.

Prerequisites from official documentation are as follows:

  • A device running Android 2.3 (Gingerbread) or newer, and Google Play services 9.2.1 or newer
  • The Google Play services SDK from the Android SDK Manager
  • Android Studio 1.5 or higher
  • An Android Studio project and its package name

First of all complete all the steps mentioned in a link you had followed for Firebase

And note that it requires active internet connection so please check internet connection and add both project and app level dependencies as per suggested in link of Firebase you had used in question

Also it is best to use JDK version 1.8 and above because oracle officialy ended support for those versions. If you are working with Firebase Api which is quiet new so i would highly recommend as it is also recommended by most professionals including developers at Google.Or if you want to go with JDK 1.7 then update it to latest Jdk 7u80 or 7u79 at least because it has least issues comparing to older versions.

The best solution is use JDK version 1.8 and follow all the steps in link https://firebase.google.com/docs/android/setup#add_the_sdk

Ensure that you have the google-services.json file, with the client id : <effective package name> , in the app directory. This you download from the Firebase console when you add an app.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM