{"id":19561109,"url":"https://github.com/heimashi/debug_view_kotlin","last_synced_at":"2025-07-14T12:35:05.580Z","repository":{"id":89281911,"uuid":"115178706","full_name":"heimashi/debug_view_kotlin","owner":"heimashi","description":"用kotlin实现的Android浮层调试控制台，实时的显示内存、FPS、文字log、app启动时间、Activity启动时间","archived":false,"fork":false,"pushed_at":"2018-01-23T07:20:49.000Z","size":396,"stargazers_count":139,"open_issues_count":1,"forks_count":16,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-27T00:31:51.585Z","etag":null,"topics":["android","debugging-tool","debugview","fps","kotlin","memory"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/heimashi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-12-23T07:22:52.000Z","updated_at":"2024-12-06T03:00:29.000Z","dependencies_parsed_at":"2023-03-03T08:00:38.623Z","dependency_job_id":null,"html_url":"https://github.com/heimashi/debug_view_kotlin","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/heimashi/debug_view_kotlin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heimashi%2Fdebug_view_kotlin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heimashi%2Fdebug_view_kotlin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heimashi%2Fdebug_view_kotlin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heimashi%2Fdebug_view_kotlin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/heimashi","download_url":"https://codeload.github.com/heimashi/debug_view_kotlin/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/heimashi%2Fdebug_view_kotlin/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265292295,"owners_count":23742028,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","debugging-tool","debugview","fps","kotlin","memory"],"created_at":"2024-11-11T05:09:48.769Z","updated_at":"2025-07-14T12:35:05.572Z","avatar_url":"https://github.com/heimashi.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"debug_view_kotlin\n=================\n\nDebug-View是用Kotlin实现的用于Android调试的**浮层调试控制台**，这个控制台会一直浮在app的UI最上层，\n用于实时地、直观地显示app的性能指标和日志信息：App使用的内存信息、App的实时帧率FPS、app启动时间、Activity启动时间、文字log信息。\n\n- 推荐项目[kotlin_tips](https://github.com/heimashi/kotlin_tips)，用Kotlin去提高生产力:汇总Kotlin相对于Java的优势，以及怎么用Kotlin去简洁、务实、高效、安全开发的Tips\n- 推荐项目[easy_mock_api](https://github.com/heimashi/easy_mock_api)，给客户端同学的模拟json接口的小工具\n- 推荐项目[CompatWebView](https://github.com/heimashi/CompatWebView)，CompatWebView is used to fix addJavascriptInterface below Android 4.2\n\n\nHow to use\n----------\n![debug_view](imgs/example_debug_view.png)\n\n- 开启浮层权限：在App首次启动时，Debug-View可能会去请求开启浮层权限，开启后才能显示控制台\n- 浮层Debug-View的区域说明：\n    - 如上图所示，浮层分为两个部分：左下角的矩形区域为控制区域，右上角的大矩形区域为显示日志区域，该区域不接收点击事件和焦点，会显示如下三种信息：\n        - 内存信息：Mem为手机剩余内存、Pss为应用所使用的总内存（包括共有的）、PD为应用的TotalPrivateDirty内存（私有的）\n        - 帧率FPS：手机的实时帧率FPS\n        - 启动时间：App启动时间以及Activity启动时间\n        - 文字Log：通过LogModule.instance.log(\"msg...\")向浮层控制台输出任意日志\n    - 浮层的控制说明\n        - 点击左下角的控制区域（短按），会清空日志控制台信息\n        - 长按左下角的控制区域（长按），会隐藏或者显示右上角的浮层控制台\n\n\nHow to import\n-------------\n- 对于已经支持kotlin的项目,在Application的module里添加依赖即可\n```groovy\n   dependencies {\n     debugImplementation 'com.sw.debug.view:debug-view:1.0.2'\n     releaseImplementation 'com.sw.debug.view:debug-view-no-op:1.0.2'\n     testImplementation 'com.sw.debug.view:debug-view-no-op:1.0.2'\n   }\n```\n如果是java项目需要先添加kotlin的支持，步骤是在Android Studio中选择tools ---\u003e kotlin ---\u003e Configure Kotlin in Project\n\n- 初始化，建议在应用的Application中，初始化后debug-view就会生成一个浮层View显示内存和FPS\n```kotlin\n    private fun initDebugView() {\n        DebugViewWrapper.instance.init(\n                DebugViewWrapper.Builder(this)\n                        .viewWidth(250) /* the width of debug-view */\n                        .bgColor(0x6f677700) /* the color of debug-view */\n                        .alwaysShowOverlaySetting(true) /* the flag for always showing Overlay Setting */\n                        .logMaxLines(20) /* the max lines of log */\n        )\n\n\n        DebugViewWrapper.instance.show()\n    }\n```\n\n- 自定义输出文字log到浮层控制台中\n```kotlin\n    LogModule.instance.log(\"some msg...\")\n```\n\n- 统计应用的启动时间（详细见example案例）\n    - 一般以Application中的attachBaseContext()作为应用启动的开始点，故在attachBaseContext()方法中调用\n    ```kotlin\n      TimerModule.instance.begin(application)\n    ```\n    - 一般以主页显示出来作为应用启动的结束点，故在MainActivity中的onWindowFocusChanged()函数中调用（不要在Activity的onResume中调用，此时Activity还未完全显示）\n    ```kotlin\n      override fun onWindowFocusChanged(hasFocus: Boolean) {\n          super.onWindowFocusChanged(hasFocus)\n          if(hasFocus){\n              TimerModule.instance.end(application)\n          }\n      }\n    ```\n\n- 统计Activity的启动时间\n    - 一般项目中都有BaseActivity，以BaseActivity的onCreate作为启动的开始点：\n    ```kotlin\n       TimerModule.instance.begin(this)\n    ```\n    - 同理在BaseActivity的onWindowFocusChanged()作为启动的结束点：\n    ```kotlin\n    override fun onWindowFocusChanged(hasFocus: Boolean) {\n        super.onWindowFocusChanged(hasFocus)\n        if(hasFocus){\n            TimerModule.instance.end(this)\n        }\n    }\n    ```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheimashi%2Fdebug_view_kotlin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fheimashi%2Fdebug_view_kotlin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheimashi%2Fdebug_view_kotlin/lists"}