Crash: Unable to create application com.myapp.MyApplication: java.lang.IllegalStateException: the DownloadMgrInitialParams is only can be touched in the process which the download service settles on
Hey there,
I'm experiencing a crash with following stack trace:
Fatal Exception: java.lang.RuntimeException: Unable to create application com.myapp.MyApplication: java.lang.IllegalStateException: the DownloadMgrInitialParams is only can be touched in the process which the download service settles on
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4293)
at android.app.ActivityThread.access$1400(ActivityThread.java:143)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1301)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4960)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
at dalvik.system.NativeStart.main(NativeStart.java)
Caused by java.lang.IllegalStateException: the DownloadMgrInitialParams is only can be touched in the process which the download service settles on
at com.liulishuo.filedownloader.util.FileDownloadHelper.initializeDownloadMgrParams(FileDownloadHelper.java:58)
at com.liulishuo.filedownloader.FileDownloader.init(FileDownloader.java:101)
at com.liulishuo.filedownloader.FileDownloader.init(FileDownloader.java:68)
at br.com.hotmart.hifire.HiFireApplication.setupFileDownloader(HiFireApplication.java:74)
at br.com.hotmart.hifire.HiFireApplication.onCreate(HiFireApplication.java:46)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1014)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4290)
at android.app.ActivityThread.access$1400(ActivityThread.java:143)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1301)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4960)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
at dalvik.system.NativeStart.main(NativeStart.java)
Here is the main code from my Application class:
public class MyApplication extends MultiDexApplication implements Application.ActivityLifecycleCallbacks {
@Override
public void onCreate() {
super.onCreate();
// some code before....
setupFileDownloader();
// some code after...
}
private void setupFileDownloader() {
FileDownloadHelper.OkHttpClientCustomMaker okHttp =
new FileDownloadHelper.OkHttpClientCustomMaker() { // is not has to provide.
@Override
public OkHttpClient customMake() {
final OkHttpClient.Builder builder = new OkHttpClient.Builder();
builder.authenticator(new AppAuthenticator(getApplicationContext()));
return builder.build();
}
};
/*
* Just for cache Application's Context, and ':filedownloader' progress will NOT be launched
* by below code, so please do not worry about performance.
*/
FileDownloader.init(getApplicationContext(), okHttp);
}
}
I get this crash reported from Crashlytics, in production. It occurs with a very low frequency, and I can't reproduce the wrong behavior in development environment. So, I would like some help about what is the expected behavior of the Library in my Application, and what could went wrong.
The code in your Application is right, but the crash stack is very oddness......
But I find one running flow can occur such crash on very low probability:
The result is null or empty from ActivityManager#getRunningAppProcesses() ( this is possible ) And the class loader of FileDownloadUtils is freed when the calling stack is invoking FileDownloadHelper#initializeDownloadMgrParams. So I will fix it.
Great! Thank you for support! Let me know when you release the new version.
@hugonardo Tonight.