Android:无法实例化 C2DMBaseReceiver

发布于 2024-11-15 05:38:06 字数 2443 浏览 0 评论 0原文

我直接将所有三个 C2DM 类从 Google Code 的 ChomeToPhone 扩展复制到我的项目中 (http://code.google.com/p/chrometophone/.../c2dm),然后修改我的按照 Android 云到设备消息传递框架页面上的说明进行清单。当我运行我的程序时,出现以下错误。我不明白发生了什么或为什么:

06-12 18:50:43.243: ERROR/AndroidRuntime(923): FATAL EXCEPTION: main
06-12 18:50:43.243: ERROR/AndroidRuntime(923): java.lang.RuntimeException: Unable to instantiate receiver com.name.asdf.C2DMBaseReceiver: java.lang.InstantiationException: com.name.asdf.C2DMBaseReceiver
06-12 18:50:43.243: ERROR/AndroidRuntime(923):     at android.app.ActivityThread.handleReceiver(ActivityThread.java:2789)
06-12 18:50:43.243: ERROR/AndroidRuntime(923):     at android.app.ActivityThread.access$3200(ActivityThread.java:125)
06-12 18:50:43.243: ERROR/AndroidRuntime(923):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2083)
06-12 18:50:43.243: ERROR/AndroidRuntime(923):     at android.os.Handler.dispatchMessage(Handler.java:99)
06-12 18:50:43.243: ERROR/AndroidRuntime(923):     at android.os.Looper.loop(Looper.java:123)
06-12 18:50:43.243: ERROR/AndroidRuntime(923):     at android.app.ActivityThread.main(ActivityThread.java:4627)
06-12 18:50:43.243: ERROR/AndroidRuntime(923):     at java.lang.reflect.Method.invokeNative(Native Method)
06-12 18:50:43.243: ERROR/AndroidRuntime(923):     at java.lang.reflect.Method.invoke(Method.java:521)
06-12 18:50:43.243: ERROR/AndroidRuntime(923):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
06-12 18:50:43.243: ERROR/AndroidRuntime(923):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
06-12 18:50:43.243: ERROR/AndroidRuntime(923):     at dalvik.system.NativeStart.main(Native Method)
06-12 18:50:43.243: ERROR/AndroidRuntime(923): Caused by: java.lang.InstantiationException: com.name.asdf.C2DMBaseReceiver
06-12 18:50:43.243: ERROR/AndroidRuntime(923):     at java.lang.Class.newInstanceImpl(Native Method)
06-12 18:50:43.243: ERROR/AndroidRuntime(923):     at java.lang.Class.newInstance(Class.java:1429)
06-12 18:50:43.243: ERROR/AndroidRuntime(923):     at android.app.ActivityThread.handleReceiver(ActivityThread.java:2780)
06-12 18:50:43.243: ERROR/AndroidRuntime(923):     ... 10 more

I directly copied all three C2DM classes into my project from Google Code's ChomeToPhone extension (http://code.google.com/p/chrometophone/.../c2dm), and then modified my Manifest per the instructions on the Android Cloud to Device Messaging Framework page. When I run my program, I get the following error. I can't figure out what's going on or why:

06-12 18:50:43.243: ERROR/AndroidRuntime(923): FATAL EXCEPTION: main
06-12 18:50:43.243: ERROR/AndroidRuntime(923): java.lang.RuntimeException: Unable to instantiate receiver com.name.asdf.C2DMBaseReceiver: java.lang.InstantiationException: com.name.asdf.C2DMBaseReceiver
06-12 18:50:43.243: ERROR/AndroidRuntime(923):     at android.app.ActivityThread.handleReceiver(ActivityThread.java:2789)
06-12 18:50:43.243: ERROR/AndroidRuntime(923):     at android.app.ActivityThread.access$3200(ActivityThread.java:125)
06-12 18:50:43.243: ERROR/AndroidRuntime(923):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2083)
06-12 18:50:43.243: ERROR/AndroidRuntime(923):     at android.os.Handler.dispatchMessage(Handler.java:99)
06-12 18:50:43.243: ERROR/AndroidRuntime(923):     at android.os.Looper.loop(Looper.java:123)
06-12 18:50:43.243: ERROR/AndroidRuntime(923):     at android.app.ActivityThread.main(ActivityThread.java:4627)
06-12 18:50:43.243: ERROR/AndroidRuntime(923):     at java.lang.reflect.Method.invokeNative(Native Method)
06-12 18:50:43.243: ERROR/AndroidRuntime(923):     at java.lang.reflect.Method.invoke(Method.java:521)
06-12 18:50:43.243: ERROR/AndroidRuntime(923):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
06-12 18:50:43.243: ERROR/AndroidRuntime(923):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
06-12 18:50:43.243: ERROR/AndroidRuntime(923):     at dalvik.system.NativeStart.main(Native Method)
06-12 18:50:43.243: ERROR/AndroidRuntime(923): Caused by: java.lang.InstantiationException: com.name.asdf.C2DMBaseReceiver
06-12 18:50:43.243: ERROR/AndroidRuntime(923):     at java.lang.Class.newInstanceImpl(Native Method)
06-12 18:50:43.243: ERROR/AndroidRuntime(923):     at java.lang.Class.newInstance(Class.java:1429)
06-12 18:50:43.243: ERROR/AndroidRuntime(923):     at android.app.ActivityThread.handleReceiver(ActivityThread.java:2780)
06-12 18:50:43.243: ERROR/AndroidRuntime(923):     ... 10 more

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

┈┾☆殇 2024-11-22 05:38:06

C2DMBaseReceiver 是一个抽象类,您无法实例化它。您应该子类化C2DMBaseReceiver并提供您自己的实现。然后在清单中注册该类。请注意,您应该将该类放在包的根目录中。

C2DMBaseReceiver is an abstract class, you can't instantiate it. You should subclass C2DMBaseReceiver and provide your own implementation. Then register that class in your manifest. Note that you should put that class in the root of your package.

无戏配角 2024-11-22 05:38:06

C2DMBaseReceiver是抽象类:
public Abstract class C2DMBaseReceiver extends IntentService{...}

抽象类无法实例化,但可以进行子类化。

C2DMBaseReceiver is abstract class:
public abstract class C2DMBaseReceiver extends IntentService{...}

Abstract classes cannot be instantiated, but they can be subclassed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文