AndroidBitmapMonitor icon indicating copy to clipboard operation
AndroidBitmapMonitor copied to clipboard

(Bug)初始化偶现崩溃问题

Open yinshengpan opened this issue 2 years ago • 1 comments

implementation "io.github.shixinzhang:android-bitmap-monitor:1.1.0"

        val ctx = ContextUtils.getApplication()
        val cacheFile = File(ctx.cacheDir, "bitmap_monitor")
        if (!cacheFile.exists()) {
            cacheFile.mkdirs()
        }
        val config = BitmapMonitor.Config.Builder()
            // 检查图片是否被回收的间隔,单位:秒 (建议不要太频繁,默认 5秒)
            .checkRecycleInterval(10L)
            // 获取堆栈的阈值,当一张图片占据的内存超过这个数值后就会去抓栈
            .getStackThreshold(100 * 1024L)
            // 还原图片的阈值,当一张图占据的内存超过这个数值后,就会还原出一张原始图片
            .restoreImageThreshold(100 * 1024L)
            .restoreImageDirectory(cacheFile.absolutePath)
            // 是否展示悬浮窗,可实时查看内存大小(建议只在 debug 环境打开)
            .showFloatWindow(true)
            // 重启后清除本地所有文件(目前不支持展示历史数据,所以默认清除本地所有)
            .clearAllFileWhenRestartApp(true)
            // 运行时超出阈值就清理
            .clearFileWhenOutOfThreshold(false)
            // 本地图片缓存写入上限,单位为 byte,默认大小为 512MB,超出后会立刻删除
            .diskCacheLimitBytes(100 * 1024 * 1024L)
            .isDebug(true)
            .context(ctx)
            .build()
        BitmapMonitor.init(config)
java.lang.NullPointerException
	at java.io.File.<init>(File.java:283)
	at top.shixinzhang.bitmapmonitor.internal.BitmapFileWatcher.loadAllFileToMemory(BitmapFileWatcher.java:103)
	at top.shixinzhang.bitmapmonitor.internal.BitmapFileWatcher.$r8$lambda$hPaKz5jeLLZ9ow_IMx3UtPDtUb8(Unknown Source:0)
	at top.shixinzhang.bitmapmonitor.internal.BitmapFileWatcher$$ExternalSyntheticLambda0.run(Unknown Source:0)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
	at java.lang.Thread.run(Thread.java:923)

yinshengpan avatar Mar 31 '23 06:03 yinshengpan

收到,感谢反馈 (╹▽╹) ,我来跟进看下 ~

yibaoshan avatar Mar 31 '23 07:03 yibaoshan