{"id":18999815,"url":"https://github.com/xuuhaoo/android-defensecrash","last_synced_at":"2025-04-15T11:13:35.825Z","repository":{"id":44725347,"uuid":"319590252","full_name":"xuuhaoo/Android-DefenseCrash","owner":"xuuhaoo","description":"Android runtime crash controller. defense java crash keep your application safety","archived":false,"fork":false,"pushed_at":"2021-10-18T03:46:07.000Z","size":160,"stargazers_count":128,"open_issues_count":2,"forks_count":38,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-15T11:13:15.415Z","etag":null,"topics":["android","android-exceptions","androidcrash","cglib","crash-reporting","exception-handling"],"latest_commit_sha":null,"homepage":"","language":"Java","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/xuuhaoo.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}},"created_at":"2020-12-08T09:33:09.000Z","updated_at":"2025-01-17T16:07:08.000Z","dependencies_parsed_at":"2022-08-30T03:11:52.413Z","dependency_job_id":null,"html_url":"https://github.com/xuuhaoo/Android-DefenseCrash","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xuuhaoo%2FAndroid-DefenseCrash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xuuhaoo%2FAndroid-DefenseCrash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xuuhaoo%2FAndroid-DefenseCrash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xuuhaoo%2FAndroid-DefenseCrash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xuuhaoo","download_url":"https://codeload.github.com/xuuhaoo/Android-DefenseCrash/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249058384,"owners_count":21205911,"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","android-exceptions","androidcrash","cglib","crash-reporting","exception-handling"],"created_at":"2024-11-08T18:05:12.432Z","updated_at":"2025-04-15T11:13:35.802Z","avatar_url":"https://github.com/xuuhaoo.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Android Defense Crash\n\n[![](https://jitpack.io/v/xuuhaoo/Android-DefenseCrash.svg)](https://jitpack.io/#xuuhaoo/Android-DefenseCrash)\n[![TonyStark](https://img.shields.io/badge/TonyStark-IronMan-red.svg)]()\n\n为了方便中国同学,提供了翻译文档如下:[中文文档](https://github.com/xuuhaoo/Android-DefenseCrash/blob/main/README_CN.md)\n### What's this\nThis’s a `Crash Defense` library in Android to help you catch the `Java exceptions` which you don’t expected.\n\n### Integration\n\n* Step 1 Find the `build.gradle` file in your project and add the code into it as follow.\n\n```groovy\nallprojects {\n  repositories {\n    //other mavens\n    maven { url 'https://jitpack.io' }\n  }\n}\n```\n\n* Step 2 Find the `build.gradle` file in the module that you want to integration\n\n```groovy\ndependencies {\n    implementation 'com.github.xuuhaoo:Android-DefenseCrash:last.version’\n}\n```\n\u003e Attentions: `last.version`is a substitute word, the real version will be found in [![](https://jitpack.io/v/xuuhaoo/Android-DefenseCrash.svg)](https://github.com/xuuhaoo/Android-DefenseCrash/releases/latest)\n\n### Use\n* Initialize should be more earlier in application create, we suggest you put the init code in `Application` `attachBaseContext(base:Context)`\n\t* Sample\n\n\t```kotlin\n  override fun attachBaseContext(base: Context) {\n    super.attachBaseContext(base)\n    DefenseCrash.initialize(this)\n    ...\n  }\n\t```\n* Install Defense library after initialize.\n\t* Sample\n\n\t```kotlin\n  override fun attachBaseContext(base: Context) {\n    super.attachBaseContext(base)\n    DefenseCrash.initialize(this)\n    DefenseCrash.install { thread, throwable, isSafeMode, isCrashInChoreographer -\u003e\n      //thread: The crash happened’s thread.\n      //throwable: The Exception exactly is.\n      //isSafeMode: If application is allready crashed and we saved it that is mean you are in safe mode,\n      //that happens most of the time is your Main Looper is compromised by some errors and not going to normal,and we keep it runing that’s called safe mode.\n      //isCrashInChoreographer: If crash happend in OnMeasure/OnLayout/OnDraw it will case screen blank or some view not draw successfully\n      //If you got this true, we suggest you restart or finish the current Activity for good\n\n      //You can throw some throwables here and if you do that, will case VM got this throwable and shutdown your process.\n      //And you should do somting here such as:\n      Log.i(\"Exceptionhandler\",\n        \"thread:${thread.name} \" +\n        \"exception:${throwable.message} \" +\n        \"isCrashInChoreographer:$isCrashInChoreographer \" +\n        \"isSafeMode:$isSafeMode\")\n      throwable.printStackTrace()\n      FirebaseCrashlytics.getInstance().recordException(throwable);\n    }\n  }\n\t```\n\n* Uninstall Defense library if you don’t need this.\n\t* Sample\n\n\t```kotlin\n    DefenseCrash.unInstall()\n\t```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxuuhaoo%2Fandroid-defensecrash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxuuhaoo%2Fandroid-defensecrash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxuuhaoo%2Fandroid-defensecrash/lists"}