{"id":22165821,"url":"https://github.com/tutorialsandroid/crashx","last_synced_at":"2026-03-17T09:37:40.967Z","repository":{"id":37850288,"uuid":"176510623","full_name":"TutorialsAndroid/crashx","owner":"TutorialsAndroid","description":"This library allows launching a crash activity when the app crashes, instead of showing the hated \"Unfortunately, X has stopped\" dialog.","archived":false,"fork":false,"pushed_at":"2023-09-04T16:35:25.000Z","size":436,"stargazers_count":59,"open_issues_count":0,"forks_count":13,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-09-05T05:44:17.661Z","etag":null,"topics":["android","android-library","androiddevelopment","crash","crash-reporting","java"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TutorialsAndroid.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-19T12:48:43.000Z","updated_at":"2023-08-31T13:58:46.000Z","dependencies_parsed_at":"2022-08-08T22:01:51.361Z","dependency_job_id":null,"html_url":"https://github.com/TutorialsAndroid/crashx","commit_stats":null,"previous_names":[],"tags_count":6,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TutorialsAndroid%2Fcrashx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TutorialsAndroid%2Fcrashx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TutorialsAndroid%2Fcrashx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TutorialsAndroid%2Fcrashx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TutorialsAndroid","download_url":"https://codeload.github.com/TutorialsAndroid/crashx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227673957,"owners_count":17802303,"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-library","androiddevelopment","crash","crash-reporting","java"],"created_at":"2024-12-02T05:16:46.859Z","updated_at":"2026-03-17T09:37:35.946Z","avatar_url":"https://github.com/TutorialsAndroid.png","language":"Java","readme":"![](https://github.com/TutorialsAndroid/crashx/blob/master/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png)\n\n# CrashX  [![API](https://img.shields.io/badge/API-15%2B-brightgreen.svg?style=flat)](https://android-arsenal.com/api?level=15)  [![Known Vulnerabilities](https://snyk.io/test/github/TutorialsAndroid/CrashX/badge.svg?targetFile=library%2Fbuild.gradle)](https://snyk.io/test/github/TutorialsAndroid/CrashX?targetFile=library%2Fbuild.gradle) [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-CrashX-red.svg?style=flat-square)](https://android-arsenal.com/details/1/7581) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://GitHub.com/TutorialsAndroid/crashx)\n\nThis library allows launching a crash activity when the app crashes, instead of showing the hated \"Unfortunately, X has stopped\" dialog.\n\n**Library Availbale at JitPack.io**\n\n[![](https://jitpack.io/v/TutorialsAndroid/crashx.svg)](https://jitpack.io/#TutorialsAndroid/crashx)\n\n\n## And Don't Forget To Follow Me On Instagram\n\n\u003cp align=\"center\"\u003eFollow me on instagram to stay up-to-date https://instagram.com/a.masram444\n    \n\n**Sample Screen**\n\n![](https://github.com/TutorialsAndroid/crashx/blob/master/images/device-2019-03-19-154405.png)\n\n## How to use\n\n### One-step install\n\nAdd it in your root build.gradle at the end of repositories:\n\n\tallprojects {\n\t\trepositories {\n\t\t\t...\n\t\t\tmaven { url 'https://jitpack.io' }\n\t\t}\n\t}\n\nStep 2. Add the dependency\n\n\tdependencies {\n\t        implementation 'com.github.TutorialsAndroid:crashx:v6.0.19'\n\t}\n\n...and you are done!\n\nOf course, you can combine this library with any other crash handler such as Crashlytics, ACRA or Firebase, just set them up as you would normally.\n\n### Try it\n\nForce an app crash by throwing an uncaught exception, using something like this in your code:\n```java\nthrow new RuntimeException(\"Kinda!\");\n```\n\n### Advanced setup\n\nYou can customize the behavior of this library in several ways by setting its configuration at any moment.\nHowever, it's recommended to do it on your `Application` class so it becomes available as soon as possible.\n\nAdd a snippet like this to your `Application` class:\n```java\n@Override\npublic void onCreate() {\n    super.onCreate();\n\n    CrashConfig.Builder.create()\n        .backgroundMode(CrashConfig.BACKGROUND_MODE_SILENT) //default: CrashConfig.BACKGROUND_MODE_SHOW_CUSTOM\n        .enabled(false) //default: true\n        .showErrorDetails(false) //default: true\n        .showRestartButton(false) //default: true\n        .logErrorOnRestart(false) //default: true\n        .trackActivities(true) //default: false\n        .minTimeBetweenCrashesMs(2000) //default: 3000\n        .errorDrawable(R.drawable.ic_custom_drawable) //default: bug image\n        .restartActivity(YourCustomActivity.class) //default: null (your app's launch activity)\n        .errorActivity(YourCustomErrorActivity.class) //default: null (default error activity)\n        .eventListener(new YourCustomEventListener()) //default: null\n        .apply();\n}\n```\n\n## Customization options\n\n### Custom behavior\n\n**Here is a more detailed explanation of each option that can be set using `CrashConfig.Builder`:**\n\n```java\nlaunchWhenInBackground(int);\n```\n\u003e This method defines if the error activity should be launched when the app crashes while on background.\n\u003e There are three modes:\n\u003e - `CrashConfig.BACKGROUND_MODE_SHOW_CUSTOM`: launch the error activity even if the app is in background.\n\u003e - `CrashConfig.BACKGROUND_MODE_CRASH`: launch the default system error when the app is in background.\n\u003e - `CrashConfig.BACKGROUND_MODE_SILENT`: crash silently when the app is in background.\n\u003e\n\u003e The default is `CrashConfig.BACKGROUND_MODE_SHOW_CUSTOM`.\n\n```java\nenabled(boolean);\n```\n\u003e Defines if CrashActivity crash interception mechanism is enabled.\n\u003e Set it to `true` if you want CrashActivity to intercept crashes,\n\u003e `false` if you want them to be treated as if the library was not installed.\n\u003e This can be used to enable or disable the library depending on flavors or buildTypes.\n\u003e The default is `true`.\n\n```java\nshowErrorDetails(boolean);\n```\n\u003e This method defines if the error activity must show a button with error details.\n\u003e If you set it to `false`, the button on the default error activity will disappear, thus disabling the user from seeing the stack trace.\n\u003e The default is `true`.\n\n```java\ntrackActivities(boolean);\n```\n\u003e This method defines if the library must track the activities the user visits and their lifecycle calls.\n\u003e This is displayed on the default error activity as part of the error details.\n\u003e The default is `false`.\n\n```java\nshowRestartButton(boolean);\n```\n\u003e This method defines if the error activity must show a \"Restart app\" button or a \"Close app\" button.\n\u003e If you set it to `false`, the button on the default error activity will close the app instead of restarting.\n\u003e If you set it to `true` and your app has no launch activity, it will still display a \"Close app\" button!\n\u003e The default is `true`.\n\n```java\nlogErrorOnRestart(boolean);\n```\n\u003e This controls if the stack trace must be relogged when the custom error activity is launched.\n\u003e This functionality exists because the Android Studio default Logcat view only shows the output for the\n\u003e current process. This makes it easier to see the stack trace of the crash. You can disable it if you\n\u003e don't want an extra log.\n\u003e The default is `true`.\n\n```java\nminTimeBetweenCrashesMs(boolean);\n```\n\u003e Defines the time that must pass between app crashes to determine that we are not in a crash loop.\n\u003e If a crash has occurred less that this time ago, the error activity will not be launched and the system\n\u003e crash screen will be invoked.\n\u003e The default is `3000`.\n\n```java\nerrorDrawable(Integer);\n```\n\u003e This method allows changing the default upside-down bug image with an image of your choice.\n\u003e You can pass a resource id for a drawable or a mipmap.\n\u003e The default is `null` (the bug image is used).\n\n```java\nrestartActivity(Class\u003c? extends Activity\u003e);\n```\n\u003e This method sets the activity that must be launched by the error activity when the user presses the button to restart the app.\n\u003e If you don't set it (or set it to null), the library will use the first activity on your manifest that has an intent-filter with action\n\u003e `com.developer.crashx.RESTART`, and if there is none, the default launchable activity on your app.\n\u003e If no launchable activity can be found and you didn't specify any, the \"restart app\" button will become a \"close app\" button,\n\u003e even if `showRestartButton` is set to `true`.\n\u003e\n\u003e As noted, you can also use the following intent-filter to specify the restart activity:\n\u003e ```xml\n\u003e \u003cintent-filter\u003e\n\u003e     \u003c!-- ... --\u003e\n\u003e     \u003caction android:name=\"com.developer.crashx.RESTART\" /\u003e\n\u003e \u003c/intent-filter\u003e\n\u003e ```\n\n```java\nerrorActivity(Class\u003c? extends Activity\u003e);\n```\n\u003e This method allows you to set a custom error activity to be launched, instead of the default one.\n\u003e Use it if you need further customization that is not just strings, colors or themes (see below).\n\u003e If you don't set it (or set it to null), the library will use the first activity on your manifest that has an intent-filter with action\n\u003e `com.developer.crashx.ERROR`, and if there is none, a default error activity from the library.\n\u003e If you use this, the activity **must** be declared in your `AndroidManifest.xml`, with `process` set to `:error_activity`.\n\u003e\n\u003e Example:\n\u003e ```xml\n\u003e \u003cactivity\n\u003e     android:name=\"com.developer.crashx.sample.CustomErrorActivity\"\n\u003e     android:label=\"@string/error_title\"\n\u003e     android:process=\":error_activity\" /\u003e\n\u003e ```\n\u003e\n\u003e As noted, you can also use the following intent-filter to specify the error activity:\n\u003e ```xml\n\u003e \u003cintent-filter\u003e\n\u003e     \u003c!-- ... --\u003e\n\u003e     \u003caction android:name=\"com.developer.crashx.ERROR\" /\u003e\n\u003e \u003c/intent-filter\u003e\n\u003e ```\n\n```java\neventListener(EventListener);\n```\n\u003e This method allows you to specify an event listener in order to get notified when the library shows the error activity, restarts or closes the app.\n\u003e The EventListener you provide can not be an anonymous or non-static inner class, because it needs to be serialized by the library. The library will throw an exception if you try to set an invalid class.\n\u003e If you set it to `null`, no event listener will be invoked.\n\u003e The default is `null`.\n\n### Customization of the default activity\n\nYou can override several resources to customize the default activity:\n\n**Theme:**\n\nThe activity uses your application theme by default. It must be a child of `Theme.AppCompat` or a default one will be used.\nIf you want to specify a specific theme only for the error activity, you can do so by redeclaring it on your manifest like this:\n\n```xml\n\u003cactivity\n    android:name=\"com.developer.crashx.activity.DefaultErrorActivity\"\n    android:theme=\"@style/YourThemeHere\"\n    android:process=\":error_activity\" /\u003e\n```\n\n**Image:**\n\nBy default, an image of a bug is displayed. You can change it to any image by using the provided `errorDrawable(int)` method.\nYou can also do it the old way and create a `crash_error_image` drawable on all density buckets (mdpi, hdpi, xhdpi, xxhdpi and xxxhdpi).\n\n**Strings:**\n\nYou can provide new strings and translations for the default error activity strings by overriding the following strings:\n```xml\n\u003cstring name=\"crash_error_activity_error_occurred_explanation\"\u003eAn unexpected error occurred.\\nSorry for the inconvenience.\u003c/string\u003e\n\u003cstring name=\"crash_error_activity_restart_app\"\u003eRestart app\u003c/string\u003e\n\u003cstring name=\"crash_error_activity_close_app\"\u003eClose app\u003c/string\u003e\n\u003cstring name=\"crash_error_activity_error_details\"\u003eError details\u003c/string\u003e\n\u003cstring name=\"crash_error_activity_error_details_title\"\u003eError details\u003c/string\u003e\n\u003cstring name=\"crash_error_activity_error_details_close\"\u003eClose\u003c/string\u003e\n\u003cstring name=\"crash_error_activity_error_details_copy\"\u003eCopy to clipboard\u003c/string\u003e\n\u003cstring name=\"crash_error_activity_error_details_copied\"\u003eCopied to clipboard\u003c/string\u003e\n\u003cstring name=\"crash_error_activity_error_details_clipboard_label\"\u003eError information\u003c/string\u003e\n```\n\n*There is a `sample` project module with examples of these overrides. If in doubt, check the code in that module.*\n\n### Completely custom error activity\n\nIf you choose to create your own completely custom error activity, you can use these methods:\n\n```java\nCrashActivity.getStackTraceFromIntent(getIntent());\n```\n\u003e Returns the stack trace that caused the error as a string.\n\n```java\nCrashActivity.getAllErrorDetailsFromIntent(getIntent());\n```\n\u003e Returns several error details including the stack trace that caused the error, as a string. This is used in the default error activity error details dialog.\n\n```java\nCrashActivity.getConfigFromIntent(getIntent());\n```\n\u003e Returns the config of the library when the crash happened. Used to call some methods.\n\n```java\nCrashActivity.restartApplication(activity, config);\n```\n\u003e Kills the current process and restarts the app again with a `startActivity()` to the passed intent.\n\u003e You **MUST** call this to restart the app, or you will end up having several `Application` class instances and experience multiprocess issues.\n\n```java\nCrashActivity.restartApplicationWithIntent(activity, intent, config);\n```\n\u003e The same as `CrashActivity.restartApplication`, but allows you to specify a custom intent.\n\n```java\nCrashActivity.closeApplication(activity, eventListener);\n```\n\u003e Closes the app and kills the current process.\n\u003e You **MUST** call this to close the app, or you will end up having several Application class instances and experience multiprocess issues.\n\n**The `sample` project module includes an example of a custom error activity. If in doubt, check the code in that module.**\n\n## Using Proguard?\n\nNo need to add special rules, the library should work even with obfuscation.\n\n## Inner workings\n\nThis library relies on the `Thread.setDefaultUncaughtExceptionHandler` method.\nWhen an exception is caught by the library's `UncaughtExceptionHandler` it does the following:\n\n1. Captures the stack trace that caused the crash\n2. Launches a new intent to the error activity in a new process passing the crash info as an extra.\n3. Kills the current process.\n\nThe inner workings are based on [ACRA](https://github.com/ACRA/acra)'s dialog reporting mode with some minor tweaks. Look at the code if you need more detail about how it works.\n\n## Incompatibilities\n\n* CrashActivity will not work in these cases:\n    * With any custom `UncaughtExceptionHandler` set after initializing the library, that does not call back to the original handler.\n    * With ACRA enabled and reporting mode set to `TOAST` or `DIALOG`.\n* If your app initialization or error activity crash, there is a possibility of entering an infinite restart loop (this is checked by the library for the most common cases, but could happen in rarer cases).\n* The library has not been tested with multidex enabled. It uses Class.forName() to load classes, so maybe that could cause some problem in API\u003c21. If you test it with such configuration, please provide feedback!\n* The library has not been tested with multiprocess apps. If you test it with such configuration, please provide feedback too!\n\n## Disclaimers\n\n* This will not avoid ANRs from happening.\n* This will not catch native errors.\n* There is no guarantee that this will work on every device.\n* This library will not make you toast for breakfast :)\n\n## License\n\n* [Apache Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html)\n\n```\nCopyright 2019 CrashX\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftutorialsandroid%2Fcrashx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftutorialsandroid%2Fcrashx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftutorialsandroid%2Fcrashx/lists"}