Skip to content

Commit

Permalink
feat: Add crash saving (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aviortheking authored Aug 24, 2023
1 parent 1703479 commit acbb524
Show file tree
Hide file tree
Showing 16 changed files with 387 additions and 134 deletions.
37 changes: 0 additions & 37 deletions .github/scripts/gradlew_recursive.sh

This file was deleted.

10 changes: 4 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,14 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: set up JDK 11
- name: set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
java-version: '17'
distribution: 'temurin'
cache: gradle
- name: Build project
run: |
chmod +x .github/scripts/gradlew_recursive.sh
.github/scripts/gradlew_recursive.sh assembleDebug
run: ./gradlew assembleDebug
- name: Zip artifacts
run: zip -r assemble.zip . -i '**/build/*.apk' '**/build/*.aab' '**/build/*.aar' '**/build/*.so'
- name: Upload artifacts
Expand Down
45 changes: 26 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Lightweight & customizable crash android crash handler library

Add to you dependencies (check the latest release for the version):
- (Gradle Kotlin DSL) Add `implementation("com.dzeio:crashhandler:1.0.2")`
- (Gradle Groovy DSL) Add `implementation "com.dzeio:crashhandler:1.0.2" `
- (Gradle Groovy DSL) Add `implementation "com.dzeio:crashhandler:1.0.2"`

## Usage

Expand All @@ -33,25 +33,32 @@ _note: full featured example in the `sample` app_
Create and add this to your Application.{kt,java}

```kotlin
// create the Crash Handler
CrashHandler.Builder()
// need the application context to run
.withContext(this)
// every other items below are optionnal
// define a custom activity to use
.withActivity(ErrorActivity::class.java)

// define the preferenceManager to be able to handle crash in a custom Activity and to have the previous crash date in the logs
.withPrefs(prefs)
.withPrefsKey("com.dzeio.crashhandler.key")

// a Prefix to add at the beggining the crash message
.withPrefix("Pouet :D")

// a Suffic to add at the end of the crash message
.withSuffix("WHYYYYY")

// build & start the module
.build().setup()
// need the application context to run
.withContext(this)

// every other items below are optionnal
// define a custom activity to use
.withActivity(ErrorActivity::class.java)

// define the preferenceManager to have the previous crash date in the logs
.withPrefs(prefs)
.withPrefsKey("com.dzeio.crashhandler.key")

// a Prefix to add at the beginning the crash message
.withPrefix("Prefix")

// a Suffix to add at the end of the crash message
.withSuffix("Suffix")

// add a location where the crash logs are also exported (can be recovered as a zip ByteArray by calling {CrashHandler.getInstance().export()})
.withExportLocation(
File(this.getExternalFilesDir(null) ?: this.filesDir, "crash-logs")
)

// build & start the module
.build().setup()
```

## Build
Expand Down
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ buildscript {
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:7.4.2")
classpath("com.android.tools.build:gradle:8.1.1")

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

plugins {
id("com.android.application") version "7.4.2" apply false
id("com.android.library") version "7.4.2" apply false
id("com.android.application") version "8.1.1" apply false
id("com.android.library") version "8.1.1" apply false
id("org.jetbrains.kotlin.android") version "1.7.0" apply false
}

Expand Down
30 changes: 26 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,39 @@
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx1024m -XX:MaxPermSize=256m
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.jvmargs=-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
#
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
org.gradle.parallel=true
#Tue Jul 19 18:42:00 CEST 2022

# enable non transitive R Classes
android.nonTransitiveRClass=true

# use official kotlin style
kotlin.code.style=official

# use androidX
android.useAndroidX=true

# Disable Jetifier
android.enableJetifier=false
org.gradle.unsafe.configuration-cache=true

# Disable configuration cache
org.gradle.unsafe.configuration-cache=false

# Enable Gradle Daemon
org.gradle.daemon=true

# Enable Configure on demand
org.gradle.configureondemand=true

# Enable gradle caching
org.gradle.caching=true
org.gradle.configureondemand=true

# Enabled Build config
android.defaults.buildfeatures.buildconfig=true

# BREAK EVERYTHING
android.nonFinalResIds=false
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sun Aug 07 22:38:24 CEST 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
Empty file modified gradlew
100644 → 100755
Empty file.
Empty file modified gradlew.bat
100644 → 100755
Empty file.
3 changes: 2 additions & 1 deletion library/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {

val artifact = "crashhandler"
group = "com.dzeio"
val projectVersion = project.findProperty("version") as String? ?: "1.0.0"
val projectVersion = project.findProperty("version") as String? ?: "1.1.0"
version = projectVersion

publishing {
Expand Down Expand Up @@ -37,6 +37,7 @@ android {

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
buildConfigField("String", "VERSION", "\"$projectVersion\"")
}

testFixtures {
Expand Down
Loading

0 comments on commit acbb524

Please sign in to comment.