GoogleService failed to initialize
Solution 1
You need to place the configuration file (google-services.json
) generated by developer.google.com, as mentioned in the 2nd step of the official docs here
The process is simple
- You can select your project or create a new one.
-
Then after selecting desired services (in this case the maps service), you can generate the configuration file.
For people who have migrated to the Firebase projects they can get the same by going to Firebase Console, selecting your project and under settings you will find the configuration file.
-
Then as quoted in step 3 of the official docs here
Copy the
google-services.json
file you just downloaded into the app/ or mobile/ directory of your Android
P.S : For people downvoting this answer, please do leave a comment as to why you are down voting it.
Solution 2
[From Product Manager @ Google]
You can fix this issue by downloading and copying the google-services.json
file for your Android app by following the steps below:
- Select your app/project name and Android packagename from this link and click
Continue to Choose and configure services
. - Click
Continue to Generate Configuration files
. - Download
google-services.json
and copy the file to theapp/
ormobile/
module directory in your Android project.
If you have previously imported your Google project into Firebase, you can get the updated google-services.json from the Firebase console under Project Settings.
DO NOT COPY the PROJECT_NUMBER as suggested by one of the other answers since the google_app_id refers to your app within a Project and not the project itself.
Solution 3
In my case, the cause of this error was that the Google Services plugin for Gradle and the Play Services library were incompatible versions. Instructions for compatible versions:
1) Add the dependency to your project-level build.gradle:
classpath 'com.google.gms:google-services:1.5.0-beta2'
2) Add the plugin to your app-level build.gradle:
apply plugin: 'com.google.gms.google-services'
3) If you're using Android Studio, this is the string to add to the dependency section of your application's build.gradle file:
dependencies {
compile "com.google.android.gms:play-services:8.3.0"
}
Source: https://developers.google.com/cloud-messaging/android/client
Solution 4
I met the same problem and solved it followed the official solution.
Here are the steps:
get the configuration file
google-services.json
from this link.Copy the
google-services.json
file you just downloaded into the app/ or mobile/ directory of your Android Studio project.-
Add the dependency to your project-level build.gradle:
classpath 'com.google.gms:google-services:1.5.0-beta2'
-
Add the plugin to your app-level build.gradle:
apply plugin: 'com.google.gms.google-services'
-
Add this dependency to your app-level build.gradle:
dependencies { compile "com.google.android.gms:play-services:8.3.0" }
Solution 5
For those who face this problem even after correctly setting up play services and placing google-services.json
file in project/app
folder, the actual solution is to
Build > Rebuild Project
Possibly due to the fact that strings from json file are not integrated into compiled resources until a full rebuild is performed.
Related videos on Youtube
Zach
Updated on July 08, 2022Comments
-
Zach almost 2 years
I am using google Maps in my android application. I have created the key and added necessary permissions in manifest file. But soon I start the application I get this message in debugger:
GoogleService failed to initialize, status: 10, Missing an expected resource: 'R.string.google_app_id' for initializing Google services. Possible causes are missing google-services.json or com.google.gms.google-services gradle plugin.
I am not sure whats wrong. The Map is working fine and I can use it without any issues. My gradle file has this entry:
compile 'com.google.android.gms:play-services:8.4.0'
What is it complaining about and how do I alleviate it?
-
j2emanue over 8 yearsis this in your manifest: <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
-
Clayton Oliveira over 8 yearsLook at the step 2: developers.google.com/identity/sign-in/android/start?hl=en
-
Zach over 8 yearsI have tried both but still getting same message!
-
Abhigyan over 8 yearsIs you device play services apk updated ?
-
midoriha_senpai about 8 yearsNone of these solutions were working, but updating the Services APK seemed to do the trick!
-
Greg T almost 8 yearsUpdating from "play-services:8.4.0" to 9.2.0 fixed this for me
-
-
iaindownie over 8 yearsThanks, but this didn't work for me - Android Studio insists I have the google-services.json file also installed, although I thought it unnecessary if you followed the three steps above which should override the need for the file? Which leads to me ask: Why do I need a Google User Sign-in system if all I'm providing is basic mapping?
-
13rac1 over 8 yearsMy solution wasn't listed, so I answered the question to give people another potential solution for this problem. In your case, you may have extra libraries installed. Try only using the
com.google.android.gms:play-services-maps:8.4.0
-
RED_ over 8 yearsDo we actually need this in our apps with the new version of Google Play Services? Or is it just for Google sign in? Seems weird that the logs throw me errors as if I need it, but I might not
-
Johnny Wu over 8 years@Radix...I went to the link that you shared, but it asked me to register for Google Sign In or Google Cloud Messaging...nothing about the map. Any idea? Also, copying this json file to right under /app is kind of odd...can you clarify? Thanks much!
-
Nishant Srivastava over 8 years@JohnnyWu thats because all these services are tied to Google Play Services and hence you need to sign in. Also You need the file under the app because thats how google set it up to read the file from. Its more like the path is hardcoded and thats how google services reads the file from.
-
Roy Solberg over 8 yearsWe already had the google-services.json in our app, but we had to recreate it when upgrading to 8.4.0.
-
Andrew V. over 8 yearsI think better to use com.google.gms:google-services:1.5.0 as it's better then beta version to remove some unpredictable errors in your app.
-
Andrew V. over 8 yearssame issue, adding google-services.json didn't help, weird thing that it doesn't see my already activated gcm and wants to create each time own server key
-
Nishant Srivastava over 8 years@AndrewV. I am guessing your implementation of API keys on Google Cloud and one defined in your json are different, otherwise I donot see a reason for this to not work. A more elaborate question of what you are doing would be helpful for anyone to answer your question.
-
Will over 8 years@AndrewV. Yes I agree. The version "1.5.0-beta2" was copied from the link I gave above.
-
DarkoM over 8 years@AndrewV, could you please check if you had added necessary permissions? Interestingly I got this error because I was missing permissions for ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION.
-
JaydeepW about 8 yearsThis should be the accepted answer. Just getting rid of the message is going to definitely being up the same work to be done in future.
-
cwhsu about 8 yearssame issue here, using 8.4.0 I still need to add
R.string.google_app_id
to strings.xml if I want to get rid of that message. -
Monkey almost 8 yearsSee correct response here from the product manager at Google: stackoverflow.com/questions/34365369/…
-
Nishant Srivastava almost 8 years@AhmedMounir : That is exactly the same answer as mine. I assume you wanted to comment this for answer by Alexander.
-
zevoid almost 8 yearsFor people who use gradle-experimental plugin, google-services.json will not take effect directly. Please refer to stackoverflow.com/a/38097895/457137 for workaround.
-
Faisal Naseer almost 8 yearswhy is there no map service and just signin , analytics and cloud messaging services only
-
Nishant Srivastava almost 8 years@FaisalNaseer because you need
google-services.json
to get Google Services working. The options provided are whats available through GoogleServices.Google Services is a dependency to Maps servcie, hence it needs to be resolved. To get your Maps working you need to get an API key , as instructed here developers.google.com/maps/documentation/android-api/start -
Faisal Naseer almost 8 yearsThanks @Radix I was continuously seeing particular error message and it was disturbing. actualy my map is displaying on some devices like emulator and Samsung J1 but unfortunately its not displaying o my tablet or Note2. I thought it may be the problem.
-
Sriram almost 8 years@Radix your answer is quite similar to mine (thanks for adding the link to the Firebase console and the deep-link the download config file wizard), except that you've linked to the Sign-In docs twice in your answer which is a bit confusing since this issue can occur with any Google service such as GCM/FCM, Analytics, Sign-in etc.
-
Nishant Srivastava almost 8 years@Sriram The idea is to show the mention in official docs. The same section occurs in any Google Services, I just picked up signin as the one.
-
akshay7692 over 7 years@eosrei, using only com.google.android.gms:play-services-maps:8.4.0 worked for me, thanks !
-
Gerry over 7 yearsMy app is logging "GoogleService failed to initialize", so I checked the services, but I don't care about any of these at this time. Guess I'll just ignore the error.
-
der_michael over 7 yearsWhy is it mandatory to include the json file? Why can't I supply the id at runtime in code?
-
jjj over 7 yearscould ask question as comment
-
IgorGanapolsky about 5 yearsFile goes in /app dir, not top-level dir?