com.google.android.gsf 包找不到
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11339445/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
com.google.android.gsf package couldn't be found
提问by bahadir arslan
I am trying to use new Google Cloud Messaging system but I have some problems.
我正在尝试使用新的 Google Cloud Messaging 系统,但遇到了一些问题。
I read Getting Started document and reviewed demo app; after that I applied requirements to my application then I created a new virtual device with API 16.
我阅读了入门文档并查看了演示应用程序;之后,我将需求应用于我的应用程序,然后我创建了一个带有 API 16 的新虚拟设备。
But when I try to register my device to GCM, it fails because of this line:
但是当我尝试将我的设备注册到 GCM 时,它由于以下行而失败:
GCMRegistrar.checkDevice(getApplicationContext());
In logcat I see these errors:
在 logcat 中,我看到这些错误:
07-05 07:06:31.925: E/AndroidRuntime(691): FATAL EXCEPTION: main
07-05 07:06:31.925: E/AndroidRuntime(691): java.lang.UnsupportedOperationException: Device does not have package com.google.android.gsf
07-05 07:06:31.925: E/AndroidRuntime(691): at com.google.android.gcm.GCMRegistrar.checkDevice(GCMRegistrar.java:83)
07-05 07:06:31.925: E/AndroidRuntime(691): at aero.tav.mobile.genel.onClick(genel.java:201)
07-05 07:06:31.925: E/AndroidRuntime(691): at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:166)
07-05 07:06:31.925: E/AndroidRuntime(691): at android.os.Handler.dispatchMessage(Handler.java:99)
07-05 07:06:31.925: E/AndroidRuntime(691): at android.os.Looper.loop(Looper.java:137)
07-05 07:06:31.925: E/AndroidRuntime(691): at android.app.ActivityThread.main(ActivityThread.java:4745)
07-05 07:06:31.925: E/AndroidRuntime(691): at java.lang.reflect.Method.invokeNative(Native Method)
07-05 07:06:31.925: E/AndroidRuntime(691): at java.lang.reflect.Method.invoke(Method.java:511)
07-05 07:06:31.925: E/AndroidRuntime(691): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
07-05 07:06:31.925: E/AndroidRuntime(691): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
07-05 07:06:31.925: E/AndroidRuntime(691): at dalvik.system.NativeStart.main(Native Method)
I had added gcm.jar to my class path; I don't know what is wrong.
我已经将 gcm.jar 添加到我的类路径中;我不知道出了什么问题。
回答by thepoosh
it seems to me like you're using the wrong emulator.
在我看来,您使用了错误的模拟器。
The default emulator uses a regular Android emulator that doesn't have any Google packages and can't run all sorts of things like maps, c2dm and all sorts of stuff like that.
默认模拟器使用常规的 Android 模拟器,它没有任何 Google 软件包,也不能运行诸如地图、c2dm 之类的各种东西。
what you want to do, is create a new emulator that can support the Google APIs.
您想要做的是创建一个可以支持 Google API 的新模拟器。
then, when you run the project, choose the emulator that runs the target name Google APIs (Google Inc).
然后,当您运行项目时,选择运行目标名称的模拟器 Google APIs (Google Inc).
good luck.
祝你好运。
回答by Jigar Brahmbhatt
It's probably running on a device that doesn't support GCM, so your call to GCMRegistrar.checkDevice( this ); is throwing an exception. Check your logcat to be sure.
它可能在不支持 GCM 的设备上运行,因此您调用 GCMRegistrar.checkDevice( this ); 正在抛出异常。检查您的 logcat 以确保。
If you're testing it on an emulator, make sure you have the emulator set up to use Google APIs. When you create the emulator, the create new AVD window has a "Target" box. Select something in that box that says "Google APIs".
如果您在模拟器上测试它,请确保您已将模拟器设置为使用 Google API。创建模拟器时,创建新 AVD 窗口有一个“目标”框。在该框中选择显示“Google API”的内容。