Android アプリで Application クラスをオーバーロードし、ACRAレポート システムを使用しています。私のアプリは次のようになります(実際のソースコードはこちら):
public class MyApplication extends Application
{
@Override
public void onCreate() {
ACRA.init( this );
/*
* Initialize my singletons etc
* ...
* ...
*/
super.onCreate();
}
}
私の知る限り、Application オブジェクトは 1 回だけ作成する必要があるため、onCreate メソッドは 1 回だけ呼び出す必要があります。問題は、私のクラッシュレポート( ACRA から)に次のようなものがあることです:
java.lang.RuntimeException: Unable to create service it.evilsocket.myapp.net.N ...
java.lang.RuntimeException: Unable to create service it.evilsocket.myapp.net.NetworkMonitorService: java.lang.RuntimeException: Unable to create application it.evilsocket.myapp.MyApplication: **java.lang.IllegalStateException: ACRA#init called more than once**
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2283)
at android.app.ActivityThread.access$1600(ActivityThread.java:127)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1212)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4441)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: Unable to create application it.evilsocket.myapp.MyApplication: java.lang.IllegalStateException: ACRA#init called more than once
at android.app.LoadedApk.makeApplication(LoadedApk.java:495)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2269)
... 10 more
Caused by: java.lang.IllegalStateException: ACRA#init called more than once
at org.acra.ACRA.init(ACRA.java:118)
at it.evilsocket.myapp.MyApplication.onCreate(MyApplication.java:46)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:969)
at android.app.LoadedApk.makeApplication(LoadedApk.java:492)
... 11 more
java.lang.RuntimeException: Unable to create application it.evilsocket.myapp.MyApplication: java.lang.IllegalStateException: ACRA#init called more than once
at android.app.LoadedApk.makeApplication(LoadedApk.java:495)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2269)
at android.app.ActivityThread.access$1600(ActivityThread.java:127)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1212)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4441)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: ACRA#init called more than once
at org.acra.ACRA.init(ACRA.java:118)
at it.evilsocket.myapp.MyApplication.onCreate(MyApplication.java:46)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:969)
at android.app.LoadedApk.makeApplication(LoadedApk.java:492)
... 11 more
java.lang.IllegalStateException: ACRA#init called more than once
at org.acra.ACRA.init(ACRA.java:118)
at it.evilsocket.myapp.MyApplication.onCreate(MyApplication.java:46)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:969)
at android.app.LoadedApk.makeApplication(LoadedApk.java:492)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2269)
at android.app.ActivityThread.access$1600(ActivityThread.java:127)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1212)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4441)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
アプリ onCreate が複数回呼び出されているようですが、これについて何か考えはありますか?
ノート:
- Android xml マニフェストでは、android:process="string" 属性を使用しませんでした。
- はい、初期化ルーチンで誤って MyApplication.onCreate を呼び出していないと確信しています。