android service newinstance failed no init ()

 

         在Android中使用StartService来启动一个IntentService时,出现如下错误:

android service newinstance failed no init ()


10-29 10:09:06.093: D/MessageReceiver(7194): [onReceive] android.provider.Telephony.SMS_RECEIVED
10-29 10:09:06.109: D/dalvikvm(7194): newInstance failed: no <init>()
10-29 10:09:06.117: D/AndroidRuntime(7194): Shutting down VM
10-29 10:09:06.117: W/dalvikvm(7194): threadid=1: thread exiting with uncaught exception (group=0x41b33700)
10-29 10:09:06.125: E/AndroidRuntime(7194): FATAL EXCEPTION: main
10-29 10:09:06.125: E/AndroidRuntime(7194): java.lang.RuntimeException: Unable to instantiate service com.sms.service.MessageReceiverService: java.lang.InstantiationException: can‘t instantiate class com.sms.service.MessageReceiverService; no empty constructor
10-29 10:09:06.125: E/AndroidRuntime(7194): 	at android.app.ActivityThread.handleCreateService(ActivityThread.java:2561)
10-29 10:09:06.125: E/AndroidRuntime(7194): 	at android.app.ActivityThread.access$1600(ActivityThread.java:141)
10-29 10:09:06.125: E/AndroidRuntime(7194): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1338)
10-29 10:09:06.125: E/AndroidRuntime(7194): 	at android.os.Handler.dispatchMessage(Handler.java:99)
10-29 10:09:06.125: E/AndroidRuntime(7194): 	at android.os.Looper.loop(Looper.java:137)
10-29 10:09:06.125: E/AndroidRuntime(7194): 	at android.app.ActivityThread.main(ActivityThread.java:5103)
10-29 10:09:06.125: E/AndroidRuntime(7194): 	at java.lang.reflect.Method.invokeNative(Native Method)
10-29 10:09:06.125: E/AndroidRuntime(7194): 	at java.lang.reflect.Method.invoke(Method.java:525)
10-29 10:09:06.125: E/AndroidRuntime(7194): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
10-29 10:09:06.125: E/AndroidRuntime(7194): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
10-29 10:09:06.125: E/AndroidRuntime(7194): 	at dalvik.system.NativeStart.main(Native Method)
10-29 10:09:06.125: E/AndroidRuntime(7194): Caused by: java.lang.InstantiationException: can‘t instantiate class com.sms.service.MessageReceiverService; no empty constructor
10-29 10:09:06.125: E/AndroidRuntime(7194): 	at java.lang.Class.newInstanceImpl(Native Method)
10-29 10:09:06.125: E/AndroidRuntime(7194): 	at java.lang.Class.newInstance(Class.java:1130)
10-29 10:09:06.125: E/AndroidRuntime(7194): 	at android.app.ActivityThread.handleCreateService(ActivityThread.java:2558)
10-29 10:09:06.125: E/AndroidRuntime(7194): 	... 10 more

原因是:You appear to be missing the zero-argument public constructor. Delete the String name from your current constructor (since you‘re not using it anyway), and you should be good to go.

译:缺少无参构造函数。

原因:构造函数带有参数,导致创建实例时,找不到无参构造函数……

android service newinstance failed no init (),布布扣,bubuko.com

android service newinstance failed no init ()

上一篇:JS判断web网站访问端是PC电脑还是手机


下一篇:Android Menu开源项目整合工程