Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
459 views
in Technique[技术] by (71.8m points)

android - Google Cloud Messaging register AUTHENTICATION_FAILED

I want to try Google Cloud Messaging (GCM) service, and I am faced with a problem at the beginning.

I get an error AUTHENTICATION_FAILED while trying to register a device to GCM. I searched and all I found were variations of the incorrect password. My password is correct and I am using just one account.

There are two ways to implement GCM client on Android:

  1. GCM library with additional jar, now deprecated.
  2. Google Play Services API

I started with the second of course and got this issue.

I thought the problem is in my phone, but then decided to try the first way, which worked! However, it is deprecated and requires an additional jar, which doesn't seem like the right way.

In an attempt to understand the reasons for the error, I decompiled Google Play Services jar and compared it with GCM library.

It turns out they both have a similar method, something like:

void register(Context context, String senderIds) {
    Intent intent = new Intent("com.google.android.c2dm.intent.REGISTER");
    intent.setPackage("com.google.android.gms"); // this one row are different
    setPackageNameExtra(context, intent);
    intent.putExtra("sender", senderIds);
    context.startService(intent);
}

The difference in one row:

In GCM library it is com.google.android.gsf, where gsf is Google Services Framework (I guess), and it works!

In Google Play Services API jar it is com.google.android.gms, And it does not work (AUTHENTICATION_FAILED error).

Then in GCM library I replaced "gsf" to "gms" and run. And I got the same AUTHENTICATION_FAILED error! If I enter another package, then it is not working.

What do I need to do to make it work? Should I set up something in the phone? Or is it a bug in Google Play Services? Have someone encountered such a problem?

Thanks in advance!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...