Possible Duplicate:
Android RuntimeException: Unable to instantiate the service
I am downloading my data using IntentService. My IntentService class definition is as follows:
public class DownloadService extends IntentService{
super("DownloadService");
@Override
protected void onHandleIntent(Intent intent) {
//download tasks...
}
}
AndroidManifest.xml:
<appilcation>
<service android:name="DownloadService"/>
..
..
..
</application>
LauncherActivity.java:
@Override
public void onCreate(Bundle savedInstanceState) {
..
..
..
Intent dwnldService = new Intent(this, DownloadService.class);
startService(dwnldService);
}
But still I am getting this error:
08-13 08:57:09.416: E/AndroidRuntime(942): FATAL EXCEPTION: main
08-13 08:57:09.416: E/AndroidRuntime(942): java.lang.RuntimeException: Unable to instantiate service com.app.android.DowloadService: java.lang.InstantiationException: can't instantiate class com.app.android.DowloadService; no empty constructor
08-13 08:57:09.416: E/AndroidRuntime(942): at android.app.ActivityThread.handleCreateService(ActivityThread.java:2237)
08-13 08:57:09.416: E/AndroidRuntime(942): at android.app.ActivityThread.access$1600(ActivityThread.java:123)
08-13 08:57:09.416: E/AndroidRuntime(942): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1201)
08-13 08:57:09.416: E/AndroidRuntime(942): at android.os.Handler.dispatchMessage(Handler.java:99)
08-13 08:57:09.416: E/AndroidRuntime(942): at android.os.Looper.loop(Looper.java:137)
08-13 08:57:09.416: E/AndroidRuntime(942): at android.app.ActivityThread.main(ActivityThread.java:4424)
08-13 08:57:09.416: E/AndroidRuntime(942): at java.lang.reflect.Method.invokeNative(Native Method)
08-13 08:57:09.416: E/AndroidRuntime(942): at java.lang.reflect.Method.invoke(Method.java:511)
08-13 08:57:09.416: E/AndroidRuntime(942): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
08-13 08:57:09.416: E/AndroidRuntime(942): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
08-13 08:57:09.416: E/AndroidRuntime(942): at dalvik.system.NativeStart.main(Native Method)
08-13 08:57:09.416: E/AndroidRuntime(942): Caused by: java.lang.InstantiationException: can't instantiate class com.app.android.DowloadService; no empty constructor
08-13 08:57:09.416: E/AndroidRuntime(942): at java.lang.Class.newInstanceImpl(Native Method)
08-13 08:57:09.416: E/AndroidRuntime(942): at java.lang.Class.newInstance(Class.java:1319)
08-13 08:57:09.416: E/AndroidRuntime(942): at android.app.ActivityThread.handleCreateService(ActivityThread.java:2234)
public DownloadService() {
super("Download service");
}
Try adding this to your service.