Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NDK and ANR detection warning messages #1832

Merged
3 commits merged into from
Apr 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

### Enhancements

* ANR or NDR detection warnings can be suppressed (using `enabledErrorTypes`) when plugin is excluded.
[#1832](https://github.com/bugsnag/bugsnag-android/pull/1832)

* Example app demonstrates global metadata.
[#1827](https://github.com/bugsnag/bugsnag-android/pull/1827)

Expand Down
2 changes: 1 addition & 1 deletion bugsnag-android-core/detekt-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<ID>SwallowedException:DeviceDataCollector.kt$DeviceDataCollector$catch (exception: Exception) { logger.w("Could not get locationStatus") }</ID>
<ID>SwallowedException:DeviceIdFilePersistence.kt$DeviceIdFilePersistence$catch (exc: OverlappingFileLockException) { Thread.sleep(FILE_LOCK_WAIT_MS) }</ID>
<ID>SwallowedException:JsonHelperTest.kt$JsonHelperTest$catch (e: IllegalArgumentException) { didThrow = true }</ID>
<ID>SwallowedException:PluginClient.kt$PluginClient$catch (exc: ClassNotFoundException) { logger.d("Plugin '$clz' is not on the classpath - functionality will not be enabled.") null }</ID>
<ID>SwallowedException:PluginClient.kt$PluginClient$catch (exc: ClassNotFoundException) { if (isWarningEnabled) { logger.d("Plugin '$clz' is not on the classpath - functionality will not be enabled.") } null }</ID>
<ID>ThrowsCount:JsonHelper.kt$JsonHelper$ fun jsonToLong(value: Any?): Long?</ID>
<ID>TooManyFunctions:ConfigInternal.kt$ConfigInternal : CallbackAwareMetadataAwareUserAwareFeatureFlagAware</ID>
<ID>TooManyFunctions:DeviceDataCollector.kt$DeviceDataCollector</ID>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ internal class PluginClient(
}

private val plugins: Set<Plugin>

private val ndkPlugin = instantiatePlugin(NDK_PLUGIN)
private val anrPlugin = instantiatePlugin(ANR_PLUGIN)
private val rnPlugin = instantiatePlugin(RN_PLUGIN)
private val ndkPlugin = instantiatePlugin(NDK_PLUGIN, immutableConfig.enabledErrorTypes.ndkCrashes)
private val anrPlugin = instantiatePlugin(ANR_PLUGIN, immutableConfig.enabledErrorTypes.anrs)
private val rnPlugin = instantiatePlugin(RN_PLUGIN, immutableConfig.enabledErrorTypes.unhandledRejections)

init {
val set = mutableSetOf<Plugin>()
Expand All @@ -32,12 +31,14 @@ internal class PluginClient(
plugins = set.toSet()
}

private fun instantiatePlugin(clz: String): Plugin? {
private fun instantiatePlugin(clz: String, isWarningEnabled: Boolean): Plugin? {
return try {
val pluginClz = Class.forName(clz)
pluginClz.newInstance() as Plugin
} catch (exc: ClassNotFoundException) {
logger.d("Plugin '$clz' is not on the classpath - functionality will not be enabled.")
if (isWarningEnabled) {
logger.d("Plugin '$clz' is not on the classpath - functionality will not be enabled.")
}
null
} catch (exc: Throwable) {
logger.e("Failed to load plugin '$clz'", exc)
Expand Down
2 changes: 1 addition & 1 deletion examples/sdk-app-example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ buildscript {

allprojects {
repositories {
mavenLocal()
google()
mavenCentral()
mavenLocal()
maven { // add this to use snapshots
url "https://oss.sonatype.org/content/repositories/snapshots/"
}
Expand Down