Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Issue #9: Add crash reporting via Mozilla's sentry instance. #26

Merged
merged 5 commits into from
Apr 19, 2018
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ android {
compileSdkVersion 27

defaultConfig {
applicationId "org.mozilla.phoenix"
applicationId "mozilla.fenix"

minSdkVersion 21
targetSdkVersion 27
Expand All @@ -26,16 +26,35 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

lintOptions {
lintConfig file("${rootDir}/config/lint.xml")
}
}

dependencies {
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'io.sentry:sentry-android:1.7.3'

implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'

implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"

testImplementation 'junit:junit:4.12'

androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}

// -------------------------------------------------------------------------------------------------
// -- Sentry
// -------------------------------------------------------------------------------------------------

android.applicationVariants.all {
try {
def token = new File("${rootDir}/.sentry").text.trim()
buildConfigField 'String', 'SENTRY_TOKEN', '"' + token + '"'
} catch (FileNotFoundException ignored) {
buildConfigField 'String', 'SENTRY_TOKEN', 'null'
}
}
7 changes: 6 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,25 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="mozilla.fenix">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme"
android:name=".FenixApplication">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

</application>

</manifest>
25 changes: 25 additions & 0 deletions app/src/main/java/mozilla/fenix/FenixApplication.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

package mozilla.fenix

import android.app.Application
import io.sentry.Sentry
import io.sentry.android.AndroidSentryClientFactory

class FenixApplication : Application() {
override fun onCreate() {
super.onCreate()

initializeCrashReporting()
}

@Suppress( // The IDE doesn't know that the token is set dynamically gradle.
"SENSELESS_COMPARISON")
private fun initializeCrashReporting() {
if (BuildConfig.SENTRY_TOKEN != null) {
Sentry.init(BuildConfig.SENTRY_TOKEN, AndroidSentryClientFactory(this))
}
}
}
12 changes: 12 additions & 0 deletions config/lint.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<lint>
<issue id="InvalidPackage">
<!-- Sentry: it uses one SDK for desktop apps and Android apps so I assume it's
calling functions from desktop apps and silently ignoring those calls when
the functions are not available on Android. -->
<ignore path="**/sentry*.jar" />
</issue>
</lint>