我的清单文件中有错误。
service.FetchAddressIntentService没有默认的构造函数
所以我在服务类中创建了如下构造函数。
现在我越来越异..
任何建议?
08-12 21:27:36.568 20148-20148/com.sunil.location.mylocation E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.sunil.location.mylocation, PID: 20148
java.lang.RuntimeException: Unable to instantiate service service.FetchAddressIntentService: java.lang.IllegalAccessException: access to constructor not allowed
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2570)
at android.app.ActivityThread.access$1800(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5086)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalAccessException: access to constructor not allowed
at java.lang.Class.newInstanceImpl(Native Method)
at java.lang.Class.newInstance(Class.java:1208)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2567)
at android.app.ActivityThread.access$1800(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5086)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
08-12 21:32:36.611 20148-20148/com.sunil.location.mylocation I/Process﹕ Sending signal. PID: 20148 SIG: 9
FetchAddressIntentService
public class FetchAddressIntentService extends IntentService {
private static final String TAG = "fetch-address-intent-service";
private static final String TAG = FetchAddressIntentService.class.getSimpleName();
/**
* The receiver where results are forwarded from this service.
*/
protected ResultReceiver mReceiver;
/**
* This constructor is required, and calls the super IntentService(String)
* constructor with the name for a worker thread.
*/
FetchAddressIntentService(){
super(TAG);
}
public FetchAddressIntentService(String name) {
//Give the class name to worker thread
super(TAG);
}
............
}
清单
package="com.sunil.location.mylocation" >
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
android:name=".MainActivity"
android:label="@string/app_name" >
android:exported="false"/>