From 2a8d7ad10d3375d109fbf360606275bf04d612cf Mon Sep 17 00:00:00 2001 From: Bhuvaneshwaran <68098126+Bhuvaneshw@users.noreply.github.com> Date: Wed, 4 Sep 2024 19:10:26 +0530 Subject: [PATCH] Update README.md --- README.md | 70 +++++++++++++++++++++++++++---------------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index 09ee792..b4b0f21 100644 --- a/README.md +++ b/README.md @@ -25,50 +25,50 @@ A Crash Handling library for Android projects that automatically stores all cras ### 1.1 Gradle - Kotlin DSL Step 1: Project level build.gradle.kts / settings.gradle.kts -
+```
 dependencyResolutionManagement {
     repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
     repositories {
         mavenCentral()
-        maven("https://jitpack.io")
+        maven("https://jitpack.io")
     }
 }
-
+``` Step 2: Module level build.gradle
-
+```
 dependencies {
-    implementation("com.github.Bhuvaneshw:CrashHandler:$version")
+    implementation("com.github.Bhuvaneshw:CrashHandler:$version")
 }
-
+``` Replace $version with latest version
Latest Version:
[![](https://jitpack.io/v/Bhuvaneshw/CrashHandler.svg)](https://jitpack.io/#Bhuvaneshw/CrashHandler)

Example: -
+```
 dependencies {
-    implementation("com.github.Bhuvaneshw:CrashHandler:1.0.0")
+    implementation("com.github.Bhuvaneshw:CrashHandler:1.0.0")
 }
-
+``` ### 1.2 Gradle - Groovy DSL Step 1: Project level build.gradle / settings.gradle -
+```
 dependencyResolutionManagement {
     repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
     repositories {
         mavenCentral()
-        maven { url 'https://jitpack.io' }
+        maven { url 'https://jitpack.io' }
     }
 }
-
+``` Step 2: Module level build.gradle
-
+```
 dependencies {
-    implementation 'com.github.Bhuvaneshw:CrashHandler:$version'
+    implementation 'com.github.Bhuvaneshw:CrashHandler:$version'
 }
-
+```

@@ -78,7 +78,7 @@ dependencies { Extend Application with CrashHandlerApplication and call installCrashHandler()

Koltin -
+```
 class MyApp : CrashHandlerApplication() {
     init {
         installCrashHandler()
@@ -92,11 +92,11 @@ class MyApp : CrashHandlerApplication() {
         //)
     }
 }
-
+```
Java -
+```
 public class MyApp extends CrashHandlerApplication {
     @Override
     public void onCreate() {
@@ -107,16 +107,16 @@ public class MyApp extends CrashHandlerApplication {
         //initCrashHandler(Thread.currentThread(), DefaultErrorMessageFormatter.INSTANCE, new RestartAppCallback(this), new AndroidErrorLogger());
     }
 }
-
+```
Register in AndroidManifiest -
+```
 <application
         android:name=".MyApp"
         ...>
     ...
 </application>
-
+```
> [!NOTE] @@ -139,17 +139,17 @@ You can provide Custom Logger by extending [CrashLogger](crashhandler/src/main/j Provide RestartAppCallback() while initializing the crash handler

Kotlin -
+```
 class MyApp : CrashHandlerApplication() {
     init {
-        installCrashHandler(callback = RestartAppCallback(this))
+        installCrashHandler(callback = RestartAppCallback(this))
     }
 }
-
+```
Java -
+```
 public class MyApp extends CrashHandlerApplication {
     @Override
     public void onCreate() {
@@ -158,12 +158,12 @@ public class MyApp extends CrashHandlerApplication {
         initCrashHandler(
           Thread.currentThread(), 
           DefaultErrorMessageFormatter.INSTANCE,
-          new RestartAppCallback(this),
+          new RestartAppCallback(this),
           new AndroidErrorLogger()
         );
     }
 }
-
+```
### 2.4 Custom Crash Handler @@ -171,7 +171,7 @@ public class MyApp extends CrashHandlerApplication { Override startCrashHandlerActivity() and provide your custom activity class

Kotlin -
+```
 class CustomCrashHandlerApp : CrashHandlerApplication() {
 
     init {
@@ -183,11 +183,11 @@ class CustomCrashHandlerApp : CrashHandlerApplication() {
     }
 
 }
-
+```
Java -
+```
 
 public class DefaultCrashHandlerApp extends CrashHandlerApplication {
 
@@ -203,7 +203,7 @@ public class DefaultCrashHandlerApp extends CrashHandlerApplication {
     }
 }
 
-
+```
### 2.5 Loading crash data in Activity @@ -212,25 +212,25 @@ public class DefaultCrashHandlerApp extends CrashHandlerApplication {
Kotlin -
+```
 val log: ErrorLog = crashHandler.loadErrorLog()
 val errors: MutableList? = log.errors
 val simplifiedLog: String = log.simplifiedLog()
 val lastErrorTime: String? = log.lastErrorTime
-
+``` > [!TIP] > Using coroutine with IO dispatcher is recommended
Java -
+```
 ErrorLog log = CrashHandlerUtilsKt.getCrashHandler(context).loadErrorLog();
 //Works only when the context.applicationContext is an instance of CrashHandler,
 //i.e The application must implement CrashHandler, like extending CrashHandlerApplication
 List errors = log.getErrors();
 String simplifiedLog = log.simplifiedLog();
 String lastErrorTime = log.getLastErrorTime();
-
+``` ## 3. Custom Crash Handler UI