Coder Social home page Coder Social logo

icerockdev / moko-crash-reporting Goto Github PK

View Code? Open in Web Editor NEW
27.0 6.0 3.0 178 KB

Fatal and Non-Fatal reporting to Crashlytics for Kotlin Multiplatform Mobile

Home Page: https://moko.icerock.dev/

License: Apache License 2.0

Kotlin 72.60% Ruby 14.34% Swift 13.05%
crash-reporting kotlin kotlin-multiplatform kotlin-native moko android ios

moko-crash-reporting's Introduction

moko-crash-reporting GitHub license Download kotlin-version

Mobile Kotlin crash report

This is a Kotlin MultiPlatform library that provides reporting fatal and non-fatal exceptions from common code.

Table of Contents

Features

  • CrashlyticsLogger implementation of ExceptionLogger, for logging messages and non-fatals to FirebaseCrashlytics.
  • CrashReportingAntilog can be used for Napier logger to log messages and errors by ExceptionLogger

Requirements

  • Gradle version 6.8+
  • Android API 19+
  • iOS version 11.0+

Installation

root build.gradle

allprojects {
    repositories {
        mavenCentral()
    }
}

project build.gradle

dependencies {
    commonMainImplementation("dev.icerock.moko:crash-reporting-crashlytics:0.4.0") // for CrashlyticsLogger
    commonMainImplementation("dev.icerock.moko:crash-reporting-napier:0.4.0") // for CrashReportingAntilog
}

For CrashlyticsLogger need to add FirebaseCrashlytics cocoapod With mobile-multiplatform-gradle-plugin cocoapods configuration simplest: build.gradle.kts:

cocoaPods {
    podsProject = file("ios-app/Pods/Pods.xcodeproj")

    pod("MCRCDynamicProxy", onlyLink = true)
}

project Podfile

pod 'MCRCDynamicProxy', :git => 'https://github.com/icerockdev/moko-crash-reporting.git', :tag => 'release/0.4.0'
pod 'MCRCStaticReporter', :git => 'https://github.com/icerockdev/moko-crash-reporting.git', :tag => 'release/0.4.0'

On iOS side add to AppDelegate:

import FirebaseCore
import MCRCStaticReporter

...

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
    FirebaseApp.configure()
    MokoFirebaseCrashlytics.setup()
    ...
}

Usage

CrashlyticsLogger

If you haven't already, add Firebase to your project, you can see how to do it here

val logger = CrashlyticsLogger()

// setting user id in crashlytics 
logger.setUserId("User_1")

// setting custom key-value in crashlytics 
logger.setCustomValue("customValue", "customKey")

// log message in crashlytics
logger.log("Hello World")

// send non-fatal exception to crashlytics
try {
    "test".toInt()
} catch (e: NumberFormatException) {
    logger.recordException(e)
}

CrashReportingAntilog

val logger = CrashlyticsLogger() // CrashlyticsLogger for example, you can use any ExceptionLogger implementation

// initialize napier
Napier.base(antilog = CrashReportingAntilog(exceptionLogger = logger))

// All messages will be logged by exceptionLogger
Napier.d(message = "Hello World")
Napier.i(message = "This is random message", tag = "FYI")
Napier.w(message = "Something goes wrong", tag = "Alarm")
Napier.v(message = "just verbose", tag = "VERBOSE")

// throwable will be recorded by exceptionLogger
try {
    "test".toInt()
} catch (e: NumberFormatException) {
    Napier.e(message = "test is not a number", tag = "Non fatal", throwable = e)
}

Samples

Please see more examples in the sample directory.

Set Up Locally

Contributing

All development (both new features and bug fixes) is performed in the develop branch. This way master always contains the sources of the most recently released version. Please send PRs with bug fixes to the develop branch. Documentation fixes in the markdown files are an exception to this rule. They are updated directly in master.

The develop branch is pushed to master on release.

For more details on contributing please see the contributing guide.

License

Copyright 2020 IceRock MAG Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

moko-crash-reporting's People

Contributors

alex009 avatar alexpogrebnyak avatar anton6tak avatar dorofeev avatar exndy avatar sainecy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

moko-crash-reporting's Issues

Add pictures to show the application of this library

Hi. Very glad to find this library. But after reading the readme, also can not see what it looks like, I think it's better to add pictures to let people could know the usage looks like quickly😊

So. I vote for adding prints' pictures in readme

should change including napier dependency from Jcenter to mavenCentral()

when we use napier from mavenCentral in another project and it has moko-crash-reporting-napier dependency we have an error while not included

jcenter {
            content {
                ("com.github.aakira")
            }
        }
Could not find com.github.aakira:napier:1.4.1.
Required by:
    project :mpp-library > dev.icerock.moko:crash-reporting-napier:0.2.0 > dev.icerock.moko:crash-reporting-napier-iosarm64:0.2.0

Ios app crash at start with NSInvalidArgumentException

After adding this library to project as in sample, iOS app crashed at start

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[FIRInstallationsItem registeredInstallationWithJSONData:date:error:]: unrecognized selector sent to instance 0x60000121fbc0'
*** First throw call stack:
(
	0   CoreFoundation                      0x00007fff2043a126 __exceptionPreprocess + 242
	1   libobjc.A.dylib                     0x00007fff20177f78 objc_exception_throw + 48
	2   CoreFoundation                      0x00007fff20448c6f +[NSObject(NSObject) instanceMethodSignatureForSelector:] + 0
	3   CoreFoundation                      0x00007fff2043e666 ___forwarding___ + 1489
	4   CoreFoundation                      0x00007fff20440698 _CF_forwarding_prep_0 + 120
	5   MultiPlatformLibrary                0x000000010c1c1ea8 __84-[FIRInstallationsAPIService registeredInstallationWithInstallation:serverResponse:]_block_invoke + 240
	6   FBLPromises                         0x000000010a7c61a7 __38+[FBLPromise(DoAdditions) onQueue:do:]_block_invoke + 39
	7   libdispatch.dylib                   0x000000010deef8ac _dispatch_call_block_and_release + 12
	8   libdispatch.dylib                   0x000000010def0a88 _dispatch_client_callout + 8
	9   libdispatch.dylib                   0x000000010defeff3 _dispatch_main_queue_callback_4CF + 1360
	10  CoreFoundation                      0x00007fff203a8276 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
	11  CoreFoundation                      0x00007fff203a2b06 __CFRunLoopRun + 2685
	12  CoreFoundation                      0x00007fff203a1b9e CFRunLoopRunSpecific + 567
	13  GraphicsServices                    0x00007fff2b773db3 GSEventRunModal + 139
	14  UIKitCore                           0x00007fff24660af3 -[UIApplication _run] + 912
	15  UIKitCore                           0x00007fff24665a04 UIApplicationMain + 101
	16  Snow Tinder                         0x000000010a0c2dc8 main + 56
	17  libdyld.dylib                       0x00007fff20257415 start + 1
)

Update firebase libs in library

Hi,
Please update the libraries you use, we have to write all the versions of the libraries we use ourselves to avoid version conflicts. For example:
Duplicate class com.google.firebase.iid.FirebaseInstanceIdReceiver found in modules jetified-firebase-iid-20.1.5-runtime (com.google.firebase:firebase-iid:20.1.5) and jetified-firebase-messaging-23.1.0-runtime (com.google.firebase:firebase-messaging:23.1.0)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.