您的位置:首页 > 其它

Why do I get an InstantiationException if I try to start a service?

2011-10-25 10:47 316 查看
10-25 10:44:59.535: ERROR/AndroidRuntime(3185): FATAL EXCEPTION: main

10-25 10:44:59.535: ERROR/AndroidRuntime(3185): java.lang.RuntimeException: Unable to instantiate service com.xxxxx.oppo.OppoReceiver: java.lang.InstantiationException: com.babeeta.oppo.OppoReceiver

10-25 10:44:59.535: ERROR/AndroidRuntime(3185): at android.app.ActivityThread.handleCreateService(ActivityThread.java:3159)

10-25 10:44:59.535: ERROR/AndroidRuntime(3185): at android.app.ActivityThread.access$3300(ActivityThread.java:136)

10-25 10:44:59.535: ERROR/AndroidRuntime(3185): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2243)

10-25 10:44:59.535: ERROR/AndroidRuntime(3185): at android.os.Handler.dispatchMessage(Handler.java:99)

10-25 10:44:59.535: ERROR/AndroidRuntime(3185): at android.os.Looper.loop(Looper.java:143)

10-25 10:44:59.535: ERROR/AndroidRuntime(3185): at android.app.ActivityThread.main(ActivityThread.java:5068)

10-25 10:44:59.535: ERROR/AndroidRuntime(3185): at java.lang.reflect.Method.invokeNative(Native Method)

10-25 10:44:59.535: ERROR/AndroidRuntime(3185): at java.lang.reflect.Method.invoke(Method.java:521)

10-25 10:44:59.535: ERROR/AndroidRuntime(3185): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)

10-25 10:44:59.535: ERROR/AndroidRuntime(3185): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

10-25 10:44:59.535: ERROR/AndroidRuntime(3185): at dalvik.system.NativeStart.main(Native Method)

10-25 10:44:59.535: ERROR/AndroidRuntime(3185): Caused by: java.lang.InstantiationException: com.xxxxx.oppo.OppoReceiver

10-25 10:44:59.535: ERROR/AndroidRuntime(3185): at java.lang.Class.newInstanceImpl(Native Method)

10-25 10:44:59.535: ERROR/AndroidRuntime(3185): at java.lang.Class.newInstance(Class.java:1429)

10-25 10:44:59.535: ERROR/AndroidRuntime(3185): at android.app.ActivityThread.handleCreateService(ActivityThread.java:3156)

10-25 10:44:59.535: ERROR/AndroidRuntime(3185): ... 10 more

You service needs to have a public no-args constructor. Otherwize, Android will not be able to instantiate it.

So replace

public StatisticsWidgetUpdateService(String name) {
super(name);
}

with

public StatisticsWidgetUpdateService() {
super("SOME NAME");
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐