SERVICE_NOT_AVAILABLE since yesterday

4,461 views
Skip to first unread message

martianoo

unread,
Sep 11, 2012, 11:00:22 AM9/11/12
to andro...@googlegroups.com
Hello,
im developing an android app that is using GCM. But since yesterday ive been getting the error=SERVICE_NOT_AVAILABLE from google servers. Do anaybody have the same pb? I even chaged the GCM_ID otr project ID.

Markus Osmers

unread,
Sep 11, 2012, 3:40:17 PM9/11/12
to andro...@googlegroups.com
I got those Message sometimes, but finaly it works after few seconds then. Mostly i got those when the android emulator is fresh started.

You should just hang on and it should work, if you got i-net connection and permission in manifest. And i just guess it runs well before yester, so it should work at all.

Cheers

MO

Relsell Global

unread,
Sep 12, 2012, 3:23:56 AM9/12/12
to andro...@googlegroups.com
Hi 

I guess it should work if you have proper Internet connection and permissions available to application. Moreover make sure there's one logged in google account. 

Thanks 

--
You received this message because you are subscribed to the Google Groups "android-gcm" group.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-gcm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/android-gcm/-/J4wd4zwHIb4J.

For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Thanks !
We respect your patience and cooperation.!

- Regards

martianoo

unread,
Sep 13, 2012, 3:22:48 PM9/13/12
to andro...@googlegroups.com
Hi,
thanks for the reply. I created a new android virtual device. May be the one ive been using so far was kind of corrupted. The connection is made now. I just need to modify some lines of my app and i'll publish.

Regards.

praveen pandey

unread,
Feb 27, 2013, 1:39:56 AM2/27/13
to andro...@googlegroups.com


Hi ,
I am developing an android app that is using GCM. But i am  getting the error=SERVICE_NOT_AVAILABLE from google servers. Can any one suggest me what i have to do in this case .


Thanks

martianoo

unread,
Feb 27, 2013, 11:51:37 AM2/27/13
to andro...@googlegroups.com

Hi,
plz are you testing your app on an emulator? If yes which version are u using. I faced the same pb while using an emulator running android 2.2 and i solved it by deleting it and creating a new one.

Raja Babar

unread,
Jun 26, 2013, 2:27:59 AM6/26/13
to andro...@googlegroups.com
I have same problem on AVD Google Api 2.2 i have added google acount too but still gets SERVICE_NOT_AVAIALBE, i guess it is some what related to Google Play Services which is not avaiable on Emulator? Do Correct me if i'm wrong

Kenneth Corbin

unread,
Jun 27, 2013, 1:17:47 PM6/27/13
to andro...@googlegroups.com
According to the Google GCM docs, SERVICE_NOT_AVAILABLE indicates the Google servers are busy at the moment and you should try again later.  They make a point that developers should implement an exponential backoff algorithm, which basically means spread and subsequent retry attempts to the servers do not get overloaded again when everyone in the world responds to a previous SERVICE_NOT_AVAILABLE condition by resending the registration request at the same time.

If you use the GCM client library that Google provides, this is handled automatically.  If you do not, looking at the code in that library will give you a good idea how to implement what they want.

John Atkins

unread,
Jun 28, 2013, 6:50:30 AM6/28/13
to andro...@googlegroups.com
I'm also getting SERVICE_NOT_AVAILABLE

But what I don't understand is that it works fine when I use the old deprecated method of getting a registration key 

regid = GCMRegistrar.getRegistrationId(context);

and having changed my code to use the new suggested method

gcm = GoogleCloudMessaging.getInstance(context);

regid = gcm.register(SENDER_ID);

this returns an exception of SERVICE_NOT_AVAILABLE

Claude François OLOMO

unread,
Jun 28, 2013, 7:11:55 AM6/28/13
to andro...@googlegroups.com
Plz John Atkins try to create a new emulator.
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "android-gcm" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/android-gcm/Skhe3jG5DIg/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> android-gcm...@googlegroups.com.
> To post to this group, send email to andro...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/android-gcm/2374e9d3-89ee-4022-8748-82c4622c310d%40googlegroups.com.

John Atkins

unread,
Jun 28, 2013, 7:29:26 AM6/28/13
to andro...@googlegroups.com
Thanks for the reply.

This is on an actual device (a Nexus 7)

I'm new to all this but one associated thing I do not understand in the deprecated methodology is that calling 

regid = GCMRegistrar.getRegistrationId(context);

does not require a SenderID or any account details.

John Atkins

unread,
Jun 28, 2013, 7:38:14 AM6/28/13
to andro...@googlegroups.com
One other piece of information on this, when regid = gcm.register(SENDER_ID); throws an exception of SERVICE_NOT_AVAILABLE

the GCM Intent Service still fires the OnRegistered event with the correct registrationId.


Claude François OLOMO

unread,
Jun 28, 2013, 10:38:39 AM6/28/13
to andro...@googlegroups.com
John i think it's better to toroughly test your app on a virtual device before doing it on an actual device.

Its also better to download gcm jar files from google servers and working with it. Google says they no longer supports code implementing the  c2dm pattern.

http://developer.android.com/google/gcm/gs.html is the simplest way to do it as compaired to http://developer.android.com/google/gcm/adv.html




On Fri, Jun 28, 2013 at 12:38 PM, John Atkins <atkins...@gmail.com> wrote:
One other piece of information on this, when regid = gcm.register(SENDER_ID); throws an exception of SERVICE_NOT_AVAILABLE

the GCM Intent Service still fires the OnRegistered event with the correct registrationId.

--
You received this message because you are subscribed to a topic in the Google Groups "android-gcm" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/android-gcm/Skhe3jG5DIg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to android-gcm...@googlegroups.com.
To post to this group, send email to andro...@googlegroups.com.

John Atkins

unread,
Jun 28, 2013, 12:26:31 PM6/28/13
to andro...@googlegroups.com
In my opinion the emulator is too slow to be usable for real work. A device is much faster and more real world.

I just took the source code from http://developer.android.com/google/gcm/gs.html  and tried with it and it also throws the SERVICE_NOT_AVAILABLE exception with the new API.

Thanks for trying to help but I can't spend any more time on this. The old api is working fine so I'll return to trying the new api some time in the future.

Claude François OLOMO

unread,
Jun 28, 2013, 12:37:54 PM6/28/13
to andro...@googlegroups.com
Ok np im sure you might have missed smthg.


John Atkins

unread,
Jun 29, 2013, 6:13:11 AM6/29/13
to andro...@googlegroups.com
Incidentally, unless I'm even more confused than I thought I was, I am using GCM and not c2dm.

I have no c2dm jar files in the lib folder. The jar files are

android-support.v4.jar and gcm.jar

In my project that attempts to register with the newer gcm.register, I also have google-play-services.jar added

John.


On Friday, 28 June 2013 15:38:39 UTC+1, martianoo wrote:

Claude François OLOMO

unread,
Jun 29, 2013, 8:46:29 AM6/29/13
to andro...@googlegroups.com
Ok im the one who misinterpreted your ideas. What u can do is to create a GCM example project and look at our google programmers did it and emulate.

Also make sure all the needed permissions are properly set. i did it with:

GCMRegistrar.checkManifest(context);



Claude François OLOMO

unread,
Jun 29, 2013, 8:58:35 AM6/29/13
to andro...@googlegroups.com
John simply use the old method with the static methods of the GCMRegistar class it looks the new GCM API is not yet stable.

John Atkins

unread,
Jun 30, 2013, 7:18:59 AM6/30/13
to andro...@googlegroups.com
Thanks very much for that. I thought I was doing things correctly. 

I'd basically taken the Google static classes code extracts and got that to work and then took the updated extracts and could not make it work.

I'll continue with the static classes for the time being.

John.

newbie

unread,
Jul 11, 2013, 12:44:55 PM7/11/13
to andro...@googlegroups.com
Hi

I am using gcm for an app development. Here i am trying to register my device with GCm server with an emulator( Android 4.2.2 and API level is 17). While registering i am getting a service not available error . the log cat trace is below;


07-11 14:17:58.577: W/System.err(800): java.io.IOException: SERVICE_NOT_AVAILABLE 07-11 14:17:58.577: W/System.err(800): at com.google.android.gms.gcm.GoogleCloudMessaging.register(Unknown Source) 07-11 14:17:58.577: W/System.err(800): at com.exp.code.utils.AsyncRequestWeb.doInBackground(AsyncRequestWeb.java:99) 07-11 14:17:58.577: W/System.err(800): at com.exp.code.utils.AsyncRequestWeb.doInBackground(AsyncRequestWeb.java:1) 07-11 14:17:58.577: W/System.err(800): at android.os.AsyncTask$2.call(AsyncTask.java:287) 07-11 14:17:58.577: W/System.err(800): at java.util.concurrent.FutureTask.run(FutureTask.java:234) 07-11 14:17:58.590: W/System.err(800): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230) 07-11 14:17:58.590: W/System.err(800): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) 07-11 14:17:58.598: W/System.err(800): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) 07-11 14:17:58.609: W/System.err(800): at java.lang.Thread.run(Thread.java:856)

Any suggestions. I am stuck on this for a long time. Is it the problem of the firewall blocking the ports or issue with the code....

Quick replies are appreciated..this ha been going for long and i am really frustrated with this. Help me

Claude François OLOMO

unread,
Jul 11, 2013, 1:10:22 PM7/11/13
to andro...@googlegroups.com
Hi,
looks like the new GCM API is still in beta or smthg. Try to use the older API namely GCMRegistrar it might help. Also i guess you've properly followed all the necessary steps to get the service working.


--
You received this message because you are subscribed to a topic in the Google Groups "android-gcm" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/android-gcm/Skhe3jG5DIg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to android-gcm...@googlegroups.com.
To post to this group, send email to andro...@googlegroups.com.

newbie

unread,
Jul 11, 2013, 1:14:21 PM7/11/13
to andro...@googlegroups.com
Hi

Thanks for the reply.. But i need to use the new API. Is there a way i can backup my self that the new API is still in beta or not working...I cannot use the old deprecated methods..

Claude François OLOMO

unread,
Jul 11, 2013, 1:30:33 PM7/11/13
to andro...@googlegroups.com
com.google.android.gms.gcm.Goo

gleCloudMessaging.register() are you calling it in the main thread?




newbie

unread,
Jul 11, 2013, 1:50:04 PM7/11/13
to andro...@googlegroups.com
aahhhhh i am making an async call in main thread....

Claude François OLOMO

unread,
Jul 11, 2013, 2:47:42 PM7/11/13
to andro...@googlegroups.com
Ok try to spawn a new thread to handle GCM workload also try to download examples from Google devs and closely look at how they did it and emulate.

Let us know if it helped.


newbie

unread,
Jul 11, 2013, 4:22:46 PM7/11/13
to andro...@googlegroups.com
okk... will try to implement that way and keep u updated...going thru man!!!..

John Atkins

unread,
Jul 11, 2013, 5:10:14 PM7/11/13
to andro...@googlegroups.com
You might have seen my messages about a similar problem.

I could not get the new GCM method to work in my own program after I hacked the code extracts into it replacing the old static methods.

I then found the complete sample at


and tried that and it worked. Although I thought I was doing it all correctly I obviously wasn't because I kept getting service unavailable. So I took the working complete sample and used that for the basis of my new code and have not had a problem since.

I suggest you take the sample at the link above and use it with your senderId just to prove it will work. If it does work, either compare it with your source code or use it exactly as it is.

John.

newbie

unread,
Jul 11, 2013, 5:50:29 PM7/11/13
to andro...@googlegroups.com
hey guys,

i need to apologise for the silly mistake i made.. i dont know how the Google Apis got uninstalled but i installed them now and it can get the registration id. However when i try to register multiple times i get the same registration id which is expected but i always dont get it( i meant that i get service not available error) but when i restart eclipse , refresh and clean build again i get the registration id again...Any suggestions or causes for this weird behaviour....


Thanks for your earlier replies guys...

Claude François OLOMO

unread,
Jul 12, 2013, 5:19:10 AM7/12/13
to andro...@googlegroups.com
Happy to hear you have made some progress.For the id did u call unregister?


newbie

unread,
Jul 13, 2013, 4:10:15 PM7/13/13
to andro...@googlegroups.com
No i havent got to the unregister part. i guess when we unregister and register we get a new id. But when we keep on calling the register frequently we get the same id from google cache. this was mentioned at the presentation by frencesco. 

Once again thanks for your help guys and will keep posting if i have questions or issues?

newbie

unread,
Jul 15, 2013, 2:49:13 PM7/15/13
to andro...@googlegroups.com

How to implement server side code where the situation is like

Different messages to be sent to different devices based on the type of message. for example :

  1.  message type 1 to device 1, 2,3
  2. message type 2 to device 1,2,4,5,6
  3. message type 3 to device 2,4,5,7 and so on all at a time


also how does unregister work in new google cloud messaging...once we unregister can we register again.

Costin Manolache

unread,
Jul 15, 2013, 4:13:26 PM7/15/13
to andro...@googlegroups.com
Few answers:

The new com.google.android.gms.gcm.GoogleCloudMessaging API requires Google Play Services. 
If missing - the error code is SERVICE_NOT_AVAILABLE.

register() is a blocking call - it is expected you'll send the registration to your server using HTTP, which
will be done in a thread, and the code becomes a bit cleaner, and no longer requires a broadcast receiver.

unregister() is also blocking - the main use case is if you suspect your server has been hacked and you
want get new registration IDs, or you change the list of authorized senders. 
It is usually better to register once, the first time your app is installed, and 
never call unregister(). If you want the device to stop receiving messages - best way is to tell your own
server to stop sending. 

If your app uses accounts, and the account changes - you shouldn't call unregister, instead keep the 
association between 'current account' and registration ID in your server. Same for sending only 
specific types of messages to a device - your server should make this decision based on information
from the app. 

A registration ID is a pointer to an app running on a specific device - there is no guarantee that 
calling unregister/register will return a different or same registration ID. 


Costin
Message has been deleted

newbie

unread,
Jul 15, 2013, 4:28:40 PM7/15/13
to andro...@googlegroups.com
Hi
 
I do have google play services and the way i implement is in the main thread have an asynctask call and in the doinbackground create a new thread and call register method.. is this approach correct or would you like to suggest anything else.

Costin Manolache

unread,
Jul 15, 2013, 4:41:59 PM7/15/13
to andro...@googlegroups.com


On Monday, July 15, 2013 1:28:40 PM UTC-7, newbie wrote:
Hi
 
I do have google play services and the way i implement is in the main thread have an asynctask call and in the doinbackground create a new thread and call register method.. is this approach correct or would you like to suggest anything else.
 

AsyncTask is great. 

newbie

unread,
Jul 15, 2013, 5:15:50 PM7/15/13
to andro...@googlegroups.com
but it doesnt work... i have the service not availble exception.... i literally am frustrated with this exception..dude pleae help me out...

Costin Manolache

unread,
Jul 15, 2013, 11:14:15 PM7/15/13
to andro...@googlegroups.com
For help with GCM it's good to know the version of android and of PlayServices, 
some "adb logcat" snippets, if are you in emulator or a phone, what kind of network ( 
any firewall ?). Without information it's pretty hard to help. 

Testing from a real phone with a data plan or unrestricted network is probably the safest option
 to isolate problems in the code and on network/emulator.

The only generic help I can provide is that "service unavailable" can be caused by not having the 
current version of Google Play Services or not having connectivity. 

Costin

You received this message because you are subscribed to the Google Groups "android-gcm" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-gcm...@googlegroups.com.

To post to this group, send email to andro...@googlegroups.com.

newbie

unread,
Jul 16, 2013, 12:48:39 AM7/16/13
to andro...@googlegroups.com
hi costin

yes i just installed the latest version of google play services ( i had an update available) ... installed it but still same error... do i need to create a new emulator again.....anything i am missing...i included gcm.jar , google play services jar, google apis , android private libraries , android dependencies...

newbie

unread,
Jul 16, 2013, 11:56:07 AM7/16/13
to andro...@googlegroups.com
hi costin

i always call the register method to make sure that it works so i wont have any trouble when i install my app on an a device andi figured out that when i call the register method 90% i get service not available exception and 10% the response(registration id). Will this effect when my app is installed on a device or can we assume that it would work fine when installed on device. by the way how do we test the logs and stuff when the app is on a device.

Any help appreciated. Sorry for bombarding you with hell of questions.

Costin Manolache

unread,
Jul 16, 2013, 1:08:06 PM7/16/13
to andro...@googlegroups.com
Are you sure the phone has consistent network connectivity ( good signal, etc ) ? If you get a registration ID 10% of the times - it seems the code is working and the service is installed. Can you run a test and make a HTTP request to an arbitrary site when the register() fails ? 

Also: register should be called only when the app is installed or upgraded, it is wasting battery and network to call it more often than that. 

Costin 


newbie

unread,
Jul 16, 2013, 2:04:20 PM7/16/13
to andro...@googlegroups.com
I am using an emulator...i ma sure i have good connectivity. I test tried with arbitrary site and i didnt get any exception . it was running fine..anyways i will save the id if i get it again. can you post your code for the registration if possible and if its not confidential just to cross check mine.

what if there is no current version of google play services available at run time . do we need to notify user of this that he should install or update to the new one.


Any suggestions on the server side how to implement it.

Claude François OLOMO

unread,
Jul 16, 2013, 4:52:50 PM7/16/13
to andro...@googlegroups.com
Hello,
filtering needs to be done on the client side prior to sending the registration key and passed to the server into variables. Specifically the details of the device being registered. Then you can save those details alongside the id. So that whenever a massage is sent the server knows how to handle it.

As a software developer, i guess you know how to architect systems before coding. It's always important to think how it'll work before coding anythg. Analysis saves lot of headaches.

Cheers


Claude François OLOMO

unread,
Jul 16, 2013, 5:06:08 PM7/16/13
to andro...@googlegroups.com
In fact each client device needs to send details about itself, like a browser sending cookies to a web app, through a POST or GET.

Once details are server side you can persist them in your db with the registration Id for further processing.

Then when a msg needs to be forwaded to a class of device your scripts can handle the logic (if..then...else)

Reply all
Reply to author
Forward
0 new messages