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
with
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"); }
相关文章推荐
- Where do I start if I want to learn about the CPython implementation?
- Why BCP connects to SQL Server instance which start with account of Network Service fail?
- 启动tomcat7.0时报错:unable to start within 45 seconds. If the server requires more time, try increasing t
- service network restart 失败Failed to start LSB: Bring up/do....
- Exception in thread "main" java.lang.RuntimeException: Hive metastore database is not initialized. Please use schematool (e.g. ./schematool -initSchema -dbType ...) to create the schema. If needed, do
- error:org.apache.catalina.LifecycleException:Failed to start component[StandardService[Tomcat]]
- Why do Kafka consumers connect to zookeeper, and producers get metadata from brokers?
- Got an exception - java.lang.RuntimeException: Unable to get class information for @throws tag 'XXXException'.
- You get an error when you attempts to save SSIS packages to the MSDB package store if the network packet size >=16388 By
- unable to start within 45 seconds. If the server requires more time, try increasing the timeout in the server editor
- ### Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: An attempt by a client to chec
- org.jboss.deployment.DeploymentException: Trying to install an already registered mbean: jboss.jca:service=LocalTxCM,name=egmasDS
- What Can I do if "The type initializer for 'Emgu.CV.CvInvoke' threw an exception"?
- if current user do not belong to Admin Group then get Admin priviledge
- GetMeUp – How to start GUI application from service, under Windows Vista/7
- Unable to start service with null: java.lang.NullPointerException
- unable to start within 450 seconds if the server reuires more time try increasing the timeout
- Why do we get error "Call to undefined function: ora_logon()/ ocilogon()"?
- What Can I do if "The type initializer for 'Emgu.CV.CvInvoke' threw an exception"?
- Why do I get the error "The target GatherAllFilesToPublish does not exist"?