Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crashing on Android api > 24 when trying to start MapboxOfflineDownloaderService. #326

Open
Balcan opened this issue Dec 4, 2019 · 1 comment
Labels

Comments

@Balcan
Copy link

Balcan commented Dec 4, 2019

Hi! I'm having this crash in several devices with Android 8:

Fatal Exception: java.lang.RuntimeException: Error receiving broadcast Intent { act=android.net.conn.CONNECTIVITY_CHANGE flg=0x4200010 (has extras) } in io.ona.kujaku.receivers.KujakuNetworkChangeReceiver@39ceec7
       at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0(LoadedApk.java:1401)
       at android.app.-$$Lambda$LoadedApk$ReceiverDispatcher$Args$_BumDX2UKsnxLVrE6UJsJZkotuA.run(:2)
       at android.os.Handler.handleCallback(Handler.java:873)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:193)
       at android.app.ActivityThread.main(ActivityThread.java:6746)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by java.lang.IllegalStateException: Not allowed to start service Intent { cmp=com.dhis2.debug/io.ona.kujaku.services.MapboxOfflineDownloaderService (has extras) }: app is in background uid UidRecord{7159e69 u0a161 TPSL bg:+17m38s556ms idle procs:1 seq(0,0,0)}
       at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1577)
       at android.app.ContextImpl.startService(ContextImpl.java:1532)
       at android.content.ContextWrapper.startService(ContextWrapper.java:664)
       at io.ona.kujaku.receivers.KujakuNetworkChangeReceiver.resumeMapDownload(KujakuNetworkChangeReceiver.java:40)
       at io.ona.kujaku.receivers.KujakuNetworkChangeReceiver.onReceive(KujakuNetworkChangeReceiver.java:33)
       at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0(LoadedApk.java:1391)
       at android.app.-$$Lambda$LoadedApk$ReceiverDispatcher$Args$_BumDX2UKsnxLVrE6UJsJZkotuA.run(:2)
       at android.os.Handler.handleCallback(Handler.java:873)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:193)
       at android.app.ActivityThread.main(ActivityThread.java:6746)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

It is happening when trying to start the MapboxOfflineowloaderService as it is using the .startService instead of .startForegroundService.

Don't know if I am missing something.
This is how we init the library:

        KujakuLibrary.setEnableMapDownloadResume(true);
        KujakuLibrary.init(this);

Thank you!

@ekigamba
Copy link
Contributor

ekigamba commented Aug 13, 2020

@Balcan Sorry for the late reply. I recently realized that I was my notification settings for this repo were off(I did not have watching ON).

Kindly disable the map-download-resumption in the mean-time, the background restrictions are probably causing this. We added the foreground notification instead since Mapbox supports added download resumption whenever a network connection is detected. The foreground service & notification keep Mapbox alive long enough to wait for a network resumption intent.

The following initialisation should suffice

        KujakuLibrary.init(this);

Kindly also follow this https://github.com/onaio/kujaku/blob/master/sample/src/main/java/io/ona/kujaku/sample/MyApplication.java#L37

Get back in case of anything else.

This is being treated as a bug and might be deprecated. Also update to the latest version of kujaku 0.8.9 which has other bug fixes & updates from Mapbox

@ekigamba ekigamba added the bug label Aug 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants