Skip to content

Commit

Permalink
Added crashanalytics
Browse files Browse the repository at this point in the history
  • Loading branch information
myofficework000 committed Mar 31, 2024
1 parent fa5f967 commit a2556ec
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {
id 'com.google.gms.google-services'
id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin'
id 'com.apollographql.apollo3'
id 'com.google.firebase.crashlytics'
}

android {
Expand Down Expand Up @@ -107,6 +108,7 @@ dependencies {
implementation platform('androidx.compose:compose-bom:2023.03.00')
implementation 'androidx.media3:media3-exoplayer:1.2.1'
implementation 'androidx.media3:media3-ui:1.2.1'
implementation 'com.google.firebase:firebase-crashlytics:18.6.3'
// implementation 'com.google.android.ads:mediation-test-suite:3.0.0'


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.example.jetpack_compose_all_in_one.firebase.crashanalytics

import androidx.compose.runtime.Composable
import com.google.firebase.crashlytics.FirebaseCrashlytics

@Composable
fun CrashAnalyticsDemo() {
// Simulate a crash for demonstration purposes
simulateCrash()

// Log a message to Crashlytics
FirebaseCrashlytics.getInstance().log("CrashAnalyticsDemo() called")

// You can log additional information
FirebaseCrashlytics.getInstance().setCustomKey("priority", "high")

// Report non-fatal exceptions
val exception = Exception("Non-fatal exception occurred")
FirebaseCrashlytics.getInstance().recordException(exception)

// You may also use setUserId() to associate users with crashes

// Your UI Composables can go here
}

private fun simulateCrash() {
// Simulate a crash
throw RuntimeException("This is a simulated crash")
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ import com.example.jetpack_compose_all_in_one.R
import com.example.jetpack_compose_all_in_one.ui.theme.dp_15
import com.example.jetpack_compose_all_in_one.ui.theme.spaceSmall


@Composable
fun InputFields() {
Column(
Expand All @@ -72,7 +71,6 @@ fun InputFields() {
}
}


@Composable
fun SimpleTextField() {
var text by remember { mutableStateOf(TextFieldValue("")) }
Expand Down
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ buildscript {
classpath 'com.google.dagger:hilt-android-gradle-plugin:2.45'
classpath 'com.google.gms:google-services:4.3.15'
classpath "com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin:2.0.1"
classpath 'com.android.tools.build:gradle:8.1.0'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.9'
}
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
Expand Down

0 comments on commit a2556ec

Please sign in to comment.