diff --git a/app/build.gradle b/app/build.gradle index 877624e..ca51632 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -3,7 +3,7 @@ apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' apply plugin: 'kotlin-kapt' apply plugin: 'com.google.gms.google-services' -apply plugin: 'io.fabric' +apply plugin: 'com.google.firebase.crashlytics' Properties properties = new Properties() properties.load(project.rootProject.file('local.properties').newDataInputStream()) @@ -16,8 +16,8 @@ android { applicationId "com.phlox.tvwebbrowser" minSdkVersion 21 targetSdkVersion 29 - versionCode 40 - versionName "1.5.6" + versionCode 41 + versionName "1.5.7" javaCompileOptions { annotationProcessorOptions { @@ -90,5 +90,5 @@ dependencies { implementation 'de.halfbit:pinned-section-listview:1.0.0' crashlyticsImplementation 'com.google.firebase:firebase-core:17.5.0' - crashlyticsImplementation 'com.crashlytics.sdk.android:crashlytics:2.10.1' + crashlyticsImplementation 'com.google.firebase:firebase-crashlytics-ktx:17.2.1' } diff --git a/app/src/main/java/com/phlox/tvwebbrowser/activity/main/MainActivityViewModel.kt b/app/src/main/java/com/phlox/tvwebbrowser/activity/main/MainActivityViewModel.kt index 84c156d..903ee90 100644 --- a/app/src/main/java/com/phlox/tvwebbrowser/activity/main/MainActivityViewModel.kt +++ b/app/src/main/java/com/phlox/tvwebbrowser/activity/main/MainActivityViewModel.kt @@ -17,6 +17,7 @@ import com.phlox.tvwebbrowser.activity.main.view.WebViewEx import com.phlox.tvwebbrowser.model.* import com.phlox.tvwebbrowser.service.downloads.DownloadService import com.phlox.tvwebbrowser.singleton.AppDatabase +import com.phlox.tvwebbrowser.utils.LogUtils import com.phlox.tvwebbrowser.utils.StringUtils import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.GlobalScope @@ -86,6 +87,7 @@ class MainActivityViewModel: ViewModel() { } } catch (e: Exception) { e.printStackTrace() + LogUtils.recordException(e) } } } @@ -106,6 +108,7 @@ class MainActivityViewModel: ViewModel() { } } catch (e: Exception) { e.printStackTrace() + LogUtils.recordException(e) } tabsStates }.await() @@ -128,6 +131,7 @@ class MainActivityViewModel: ViewModel() { } } catch (e: Exception) { e.printStackTrace() + LogUtils.recordException(e) } try { @@ -135,6 +139,7 @@ class MainActivityViewModel: ViewModel() { jsInterface.setSuggestions(TVBro.instance, frequentlyUsedUrls) } catch (e: Exception) { e.printStackTrace() + LogUtils.recordException(e) } } diff --git a/app/src/main/java/com/phlox/tvwebbrowser/activity/main/view/WebViewEx.kt b/app/src/main/java/com/phlox/tvwebbrowser/activity/main/view/WebViewEx.kt index 6a75e21..bd3a158 100644 --- a/app/src/main/java/com/phlox/tvwebbrowser/activity/main/view/WebViewEx.kt +++ b/app/src/main/java/com/phlox/tvwebbrowser/activity/main/view/WebViewEx.kt @@ -15,6 +15,7 @@ import android.webkit.WebView import android.widget.FrameLayout import android.widget.PopupMenu import com.phlox.tvwebbrowser.R +import com.phlox.tvwebbrowser.utils.LogUtils /** * Created by fedex on 12.08.16. @@ -175,10 +176,12 @@ class WebViewEx : WebView { thumbnail = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888) } catch (e: Throwable) { e.printStackTrace() + LogUtils.recordException(e) try { thumbnail = Bitmap.createBitmap(width / 2, height / 2, Bitmap.Config.ARGB_8888) } catch (e: OutOfMemoryError) { e.printStackTrace() + LogUtils.recordException(e) } } } diff --git a/app/src/main/java/com/phlox/tvwebbrowser/model/WebTabState.kt b/app/src/main/java/com/phlox/tvwebbrowser/model/WebTabState.kt index 525068e..8865d0b 100644 --- a/app/src/main/java/com/phlox/tvwebbrowser/model/WebTabState.kt +++ b/app/src/main/java/com/phlox/tvwebbrowser/model/WebTabState.kt @@ -9,6 +9,7 @@ import android.webkit.WebChromeClient import com.phlox.tvwebbrowser.TVBro import com.phlox.tvwebbrowser.activity.main.view.WebViewEx +import com.phlox.tvwebbrowser.utils.LogUtils import com.phlox.tvwebbrowser.utils.Utils import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -70,6 +71,7 @@ data class WebTabState(var currentOriginalUrl: String? = null, var currentTitle: } } catch (e: JSONException) { e.printStackTrace() + LogUtils.recordException(e) } } @@ -96,6 +98,7 @@ data class WebTabState(var currentOriginalUrl: String? = null, var currentTitle: } } catch (e: JSONException) { e.printStackTrace() + LogUtils.recordException(e) } return store diff --git a/app/src/main/java/com/phlox/tvwebbrowser/utils/LogUtils.kt b/app/src/main/java/com/phlox/tvwebbrowser/utils/LogUtils.kt new file mode 100644 index 0000000..c7c74a9 --- /dev/null +++ b/app/src/main/java/com/phlox/tvwebbrowser/utils/LogUtils.kt @@ -0,0 +1,19 @@ +package com.phlox.tvwebbrowser.utils + +object LogUtils { + //send exception info to crashlytics in case crashlytics included in current build + fun recordException(e: Throwable) { + try { + val clazz = Class.forName("com.google.firebase.crashlytics.FirebaseCrashlytics") + val method = clazz.getMethod("getInstance") + val crashlytics = method.invoke(null) + val clazz2 = crashlytics::class.java + val method2 = clazz2.getMethod("recordException", Throwable::class.java) + method2.invoke(crashlytics, e) + } catch (ex: ClassNotFoundException) { + //thats ok - not all builds include crashlytics + } catch (ex: Exception) { + ex.printStackTrace() + } + } +} \ No newline at end of file diff --git a/build.gradle b/build.gradle index 237dcb5..2a95364 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ buildscript { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version" classpath 'com.google.gms:google-services:4.3.3' - classpath 'io.fabric.tools:gradle:1.31.1' + classpath 'com.google.firebase:firebase-crashlytics-gradle:2.2.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files