我正在尝试设置一个应用程序来使用gcm,但是根据Gcm文档,每次我得到phone_registration_error错误时,这个错误意味着:
Incorrect phone registration with Google.
This phone doesn't currently support GCM.
但我不明白为什么它不被支持,我在一台真正的android设备和一个带有google api的仿真器上进行了测试
我的MainActivity:
@Override
public void onCreate(Bundle savedInstanceState) {
checkNotNull(SENDER_ID, "SENDER_ID");
GCMRegistrar.checkDevice(this);
GCMRegistrar.checkManifest(this);
final String regId = GCMRegistrar.getRegistrationId(this);
Log.i(TAG, "registration id ===== "+regId);
if(regId.equals("")){
GCMRegistrar.register(this, SENDER_ID);
} else {
Log.v(TAG, "Already Registred");
}
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
还有我的清单:
Manifest on pastebin
发布于 2012-11-19 17:59:00
GCM只能在运行Android2.2或更新版本的设备上运行。此外,GCM只有在为设备安装了google帐户的情况下才有效。这也是谷歌建议在清单中使用<uses-permission android:name="android.permission.GET_ACCOUNTS" />
的原因,这样你就可以确保设备有谷歌账户。
发布于 2015-03-03 15:04:48
我也有同样的问题,在互联网上搜索了很多天后,我在谷歌群组(https://groups.google.com/forum/#!topic/cerberus-support-forum/eJxOsYqkTxo)中注意到了这一点,并尝试了一下,它对我来说工作得很完美。
您的Google帐户有问题。请尝试以下操作:
或
转到设置->应用->全部(在较新版本上)
为“
然后检查你的应用程序中的GCM id。
如果它仍然不能工作,然后删除所有的谷歌帐户从手机,并重新启动手机,并添加帐户再次。
它对我很有效(在实现了我在互联网上搜索到的许多解决方案之后)。
希望它能有所帮助!!
发布于 2016-06-30 16:59:44
我查看了您的清单,但您忘记传递GooglePlay服务元数据。
中
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/>
对我来说效果很好。
然后重新编译并重试。希望能有所帮助。
https://stackoverflow.com/questions/12772086
复制相似问题