java.lang.RuntimeException - 原因:java.lang.ArithmeticException

java.lang.RuntimeException - Caused by: java.lang.ArithmeticException

这是两个游戏控制台日志,我认为它们是同一个问题。
我在 Play 商店的应用程序中使用了 https://github.com/z3r0c00l-2k/AquaDroid 这个库。
但我不知道如何解决正在发生的崩溃。
请有人帮助我,还在下面发布 shallNotify 代码...请帮助

java.lang.RuntimeException:
at android.app.ActivityThread.handleReceiver (ActivityThread.java:4114)
at android.app.ActivityThread.access00 (ActivityThread.java:250)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1984)
at android.os.Handler.dispatchMessage (Handler.java:106)
at android.os.Looper.loop (Looper.java:250)
at android.app.ActivityThread.main (ActivityThread.java:7766)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:604)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:958)
Caused by: java.lang.ArithmeticException:
at myapp.w3.b.f (Unknown Source:47)
at myapp.w3.b.e (Unknown Source)
at myapp.recievers.NotifierReceiver.onReceive (Unknown Source:91)
at android.app.ActivityThread.handleReceiver (ActivityThread.java:4105)

java.lang.RuntimeException:
at android.app.ActivityThread.handleReceiver (ActivityThread.java:3798)
at android.app.ActivityThread.access00 (ActivityThread.java:220)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1871)
at android.os.Handler.dispatchMessage (Handler.java:107)
at android.os.Looper.loop (Looper.java:214)
at android.app.ActivityThread.main (ActivityThread.java:7403)
at java.lang.reflect.Method.invoke (Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:935)
Caused by: java.lang.ArithmeticException:
at myapp.helpers.NotificationHelper.shallNotify (NotificationHelper.java:47)
at myapp.helpers.NotificationHelper.notify (NotificationHelper.java)
at myapp.recievers.NotifierReceiver.onReceive (NotifierReceiver.java:91)
at android.app.ActivityThread.handleReceiver (ActivityThread.java:3789)
at android.app.ActivityThread.access00 (ActivityThread.java:220)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1871)
at android.os.Handler.dispatchMessage (Handler.java:107)
at android.os.Looper.loop (Looper.java:214)
at android.app.ActivityThread.main (ActivityThread.java:7403)
at java.lang.reflect.Method.invoke (Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:935)

        private fun shallNotify(): Boolean {
        val prefs = ctx.getSharedPreferences(AppUtils.USERS_SHARED_PREF, AppUtils.PRIVATE_MODE)
        val sqliteHelper = SqliteHelper(ctx)

        val percent = sqliteHelper.getIntook(AppUtils.getCurrentDate()!!) * 100 /      prefs.getInt(AppUtils.TOTAL_INTAKE, 0)

        var doNotDisturbOff = true

        val startTimestamp = prefs.getLong(AppUtils.WAKEUP_TIME, 0)
        val stopTimestamp = prefs.getLong(AppUtils.SLEEPING_TIME_KEY, 0)

        if (startTimestamp > 0 && stopTimestamp > 0) {
            val now = Calendar.getInstance().time

            val start = Date(startTimestamp)
            val stop = Date(stopTimestamp)

            doNotDisturbOff = compareTimes(now, start) >= 0 && compareTimes(now, stop) <= 0
        }

        return doNotDisturbOff && (percent < 100)
    }
        fun notify(id: Long, notification: NotificationCompat.Builder?) {
        if (shallNotify()) {
            getManager()!!.notify(id.toInt(), notification!!.build())
        } else {
            Log.i("AquaDroid", "dnd period")
        }
    }
        override fun onReceive(context: Context, intent: Intent) {

        val prefs = context.getSharedPreferences(AppUtils.USERS_SHARED_PREF, AppUtils.PRIVATE_MODE)
        val notificationsTone = prefs.getString(
            AppUtils.NOTIFICATION_TONE_URI_KEY, RingtoneManager.getDefaultUri(
                RingtoneManager.TYPE_NOTIFICATION
            ).toString()
        )

        val title = context.resources.getString(R.string.app_name)
        val messageToShow = prefs.getString(
            AppUtils.NOTIFICATION_MSG_KEY,
            context.resources.getString(R.string.pref_notification_message_value)
        )

        /* Notify */
        val nHelper = NotificationHelper(context)
        @SuppressLint("ResourceType") val nBuilder = messageToShow?.let {
            nHelper
                .getNotification(title, it, notificationsTone)
        }
        nHelper.notify(1, nBuilder)

    }
val percent = sqliteHelper.getIntook(AppUtils.getCurrentDate()!!) * 100 /      prefs.getInt(AppUtils.TOTAL_INTAKE, 0)

您可能在此处被零除。 sharedpreferences 默认值为 0,因此此处崩溃的一种明显方法是在 prefs 中没有 TOTAL_INTAKE 的值,或者具有零值。