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

Better SDK34 support #88

Merged
merged 25 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
de35816
Fixes #87 - Will require clean rebuild of project in AS to take effect.
TheRealAgentK Oct 26, 2023
e833269
Ignored UI settings file
TheRealAgentK Oct 26, 2023
9895669
Fixed missing Locale for String functions (via Lint)
TheRealAgentK Oct 26, 2023
baf4c8b
GSON to 2.8.9
TheRealAgentK Oct 26, 2023
2175f29
Unused String resource.
TheRealAgentK Oct 26, 2023
77aee5c
Migrating project to AndroidX, setting SDK to 34 and fixing issues in…
TheRealAgentK Oct 26, 2023
979f5a2
Updating Timber to 5.0.1, Downgrading Kotlin compiler to 1.7.x, becau…
TheRealAgentK Oct 26, 2023
36ed02d
App to SDK 34, ignored a bunch of things in linting for now that stil…
TheRealAgentK Oct 27, 2023
9bfe632
Fix DataExtractionRules lint
TheRealAgentK Nov 6, 2023
9f15d2d
Fix MonochromeLauncherIcon lint
TheRealAgentK Nov 6, 2023
fab7089
Fix SetTextI18n lint
TheRealAgentK Nov 6, 2023
d6ced5e
Fix HardcodedText lint
TheRealAgentK Nov 6, 2023
2a0f587
Comment clarification
TheRealAgentK Nov 6, 2023
46cdc90
Fixes #83, no need for jetifier anymore.
TheRealAgentK Nov 6, 2023
a4b5077
Set Kotlin to 1.8.22
TheRealAgentK Nov 6, 2023
3747a53
Documentation updates
TheRealAgentK Nov 6, 2023
0e26927
Fixing issue with format.
TheRealAgentK Nov 6, 2023
e66147a
Changelog
TheRealAgentK Nov 6, 2023
ac66642
Set build to 4.1.0 alpha1
TheRealAgentK Nov 6, 2023
39de0cd
Provider build: Upgrade androidx lib versions, remove lint exclusions.
TheRealAgentK Nov 6, 2023
05a13ec
App build: Cleanup and all dependencies up to date, Provider build: O…
TheRealAgentK Nov 6, 2023
f6e139d
Update README.md
TheRealAgentK Nov 6, 2023
6bd1e4b
Update README.md
TheRealAgentK Nov 6, 2023
a350c22
Update README.md
TheRealAgentK Nov 6, 2023
7060371
PR review comments.
TheRealAgentK Nov 6, 2023
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Thumbs.db
.idea/markdown-navigator.xml
.idea/markdown-navigator-enh.xml
.idea/markdown-navigator
.idea/deploymentTargetDropDown.xml
.idea/caches/
.gradle
build/
Expand Down
2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 21 additions & 2 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## Changelog

- v4.1.0-alpha1:
- Upgrade repo and all dependencies to SDK 34, Android X (#83) and others.
- Documented Timber linting behaviour and solution (#69).
- Upgraded all builds to Gradle 7.x to work correctly with Android Studio Giraffe (2022.3.1)

- v4.0.2-beta1:
- Added additional RaygunClient.init() entry point to make usage from within cross-platform libraries more accessible (#72)
- Debug build of the sample app now includes LeakCanary
Expand Down
57 changes: 36 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,24 @@ Supports Android 4.1+ (API 16+).

### 16 June 2020

Raygun4Android 4.0.1 is currently considered to be the stable release of the provider.
Raygun4Android 4.0.1 is currently considered to be the stable release of the provider and is tagged in the repository.

Raygun4Android 4.0.2-beta1 has a few minor bugfixes and improvements.
The master branch reflect ongoing work on the 4.1 line as snapshots.

The master branch reflect ongoing work on the 4.0.x line.
Raygun4Android is currently actively being worked on towards a release of version 5 in the near future.

Raygun4Android is currently actively being worked on towards a release of version 4.1 in a separate branch.

With the release of 4.0.0-beta2, the 4.0.0 development branch had been merged into master and is now the mainstream development line.

If you want the older stable version 3.0.6 please check out the change set labelled with v3.0.6 and go from there.
If you want the *very old* stable version 3.0.6 please check out the change set labelled with v3.0.6 and go from there.

## Requirements

- minSdkVersion 16+
- compileSdkVersion 28
- compileSdkVersion 34

## Internal dependencies

- Gson
- OKHttp
- Timber

## Installation

Expand All @@ -45,7 +47,7 @@ Then add the following to your **module's** build.gradle:
```gradle
dependencies {
...
implementation 'com.raygun:raygun4android:4.+'
implementation 'com.raygun:raygun4android:4.0.1'
TheRealAgentK marked this conversation as resolved.
Show resolved Hide resolved
}
```

Expand Down Expand Up @@ -88,11 +90,11 @@ The above exception handler automatically catches and sends all uncaught excepti

For an actual usage example, check out the sample application in the **app** module of this project

## Raygun and ProGuard
## Raygun and ProGuard/R8

### General

ProGuard is a free Java tool for obfuscation, class file shrinking, optimizing and pre-verifying. When enabling ProGuard in a native Android application that also uses Raygun, the obfuscation feature requires a bit of attention. By default, your obfuscated class and method names will show up in the stacktraces of exception/error reports submitted to Raygun. This makes the stacktraces difficult to read when looking into the cause of the issues.
ProGuard and R8 are tools for obfuscation, class file shrinking, optimizing and pre-verifying. When enabling ProGuard in a native Android application that also uses Raygun, the obfuscation feature requires a bit of attention. By default, your obfuscated class and method names will show up in the stacktraces of exception/error reports submitted to Raygun. This makes the stacktraces difficult to read when looking into the cause of the issues.
TheRealAgentK marked this conversation as resolved.
Show resolved Hide resolved

ProGuard produces a mapping.txt file that can be used to restore the original class and method names. Such files can be uploaded to Raygun to automatically process all of your exception reports into readable stacktraces.

Expand Down Expand Up @@ -174,7 +176,7 @@ def createRaygunNotifyDeploymentTask(token,key,groupName,version,userName,userEm

This function gets called from within the ```android {...}``` block of the Gradle file at each build in Android Studio and creates the appropriate parameterised task to notify the Raygun backend of your app's deployment.

## Advanced features
TheRealAgentK marked this conversation as resolved.
Show resolved Hide resolved
## Advanced Features

### Affected Customers

Expand Down Expand Up @@ -214,7 +216,7 @@ Please note that setting a custom endpoint will stop Crash Report or Real User M

### Storing crash reports on the device

If the device can't connect, Raygun4Android will save the crash report to disk. At the next start of the application (and therefore the provider) it will check if the internet is now available, and if it is, send the cached messages. A maximum of 64 messages will be cached and you can change the amount by calling:
If the device can't connect because it is offline, Raygun4Android will save the crash report to the device storage. At the next start of the application, (along with the provider) it will check if the internet is now available. If it is, send the cached messages. A maximum of 64 messages will be cached. Once the storage limit is reached, no further crash reports are stored locally until the storage has been cleared. You can change the amount by calling:

```java
RaygunClient.setMaxReportsStoredOnDevice(amount)
Expand Down Expand Up @@ -246,7 +248,6 @@ class BeforeSendImplementation implements CrashReportingOnBeforeSend {
return message;
}
}

...

public class SomeActivity extends Activity {
Expand Down Expand Up @@ -379,26 +380,26 @@ Provides an instance of a class which has an onBeforeSend method that can be use

* Is there an example app?

Yup - clone this repository then run the **app** module of the project.
Yup - clone this repository, then run the **app** module of the project.

* Not seeing errors in the dashboard?
* I'm not seeing errors in Raygun Crash Reporting.

Raygun4Android outputs Logcat messages - look for the the logcat tag **Raygun4Android**. HTTP Status 403 will indicate an invalid API key, 400 a bad message, and 202 will indicate received successfully.

* My build fails with `Default interface methods are only supported starting with Android N (--min-api 24)`. Why is that?

Raygun4Android uses Timber for internal logging. This requires some language features that are only available with Java 8. Make sure that your project using the library has set compilation compatibility to Java 8.
Raygun4Android uses Timber for internal logging. This requires some language features that are only available with Java 8. Make sure that your project, using the library, has set the compilation compatibility to Java 8 as the minimum.

Google's documentation has more information on the reasons and implications of this requirement: https://developer.android.com/studio/write/java8-support

```groovy
android {
...
compileOptions {
...
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
...
...
}
```

Expand All @@ -415,3 +416,17 @@ android {
* The library logs an error message about a not found class: Rejecting re-init on previously-failed class java.lang.Class<android.support.v4.app.JobIntentService$JobServiceEngineImpl>

The message above stems from certain versions of the Android support libraries. JobServiceEngineImpl is part of Android Oreo (8, SDK 26) and newer only. The support library catering for supporting services on earlier versions of Android runs internal checks for which implementation is available to it. As part of the checks, it outputs the message as an informational feedback only.

* Timber Lint warnings get exposed to my app even though I don't (want to) use Timber.

The solution for the time being is to disable linting for those specific lint warning in your app:
TheRealAgentK marked this conversation as resolved.
Show resolved Hide resolved

```groovy
android {
...
lintOptions {
disable 'LogNotTimber', 'StringFormatInTimber', 'ThrowableNotAtBeginning', 'BinaryOperationInTimber', 'TimberArgCount', 'TimberArgTypes', 'TimberTagLength'
}
...
}
```
36 changes: 20 additions & 16 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,17 @@ android {
storePassword '123456'
}
}
compileSdk 28
compileSdk 34
TheRealAgentK marked this conversation as resolved.
Show resolved Hide resolved
defaultConfig {
applicationId "com.raygun.raygun4androidsample"
applicationId "com.raygun.raygun4android"
minSdkVersion 16
targetSdkVersion 28
targetSdkVersion 34
versionCode = Long.valueOf(VERSION_CODE)
versionName = "${VERSION_NAME}-sample"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
lintOptions {
disable 'LogNotTimber','StringFormatInTimber', 'ThrowableNotAtBeginning', 'BinaryOperationInTimber', 'TimberArgCount', 'TimberArgTypes', 'TimberTagLength'
TheRealAgentK marked this conversation as resolved.
Show resolved Hide resolved
}
buildTypes {
release {
Expand All @@ -108,21 +111,22 @@ android {
// Setup RG tasks
createRaygunNotifyDeploymentTask(RAYGUN_API_TOKEN, RAYGUN_API_KEY, RAYGUN_GROUP, defaultConfig.versionName, localUserName, localUserEmail)
createRaygunProguardTask(RAYGUN_API_TOKEN, RAYGUN_APP_PATH, RAYGUN_GROUP, defaultConfig.versionName)
namespace 'com.raygun.raygun4androidsample.sample'
namespace 'com.raygun.raygun4android.sample'
TheRealAgentK marked this conversation as resolved.
Show resolved Hide resolved
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
// Build from local provider library src

// Usage option A: Use and build from local provider library src
implementation project(':provider')
// Build from external repo
//implementation 'com.raygun:raygun4android:4.0.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.4'
// Usage option B: Use and build from external repo
// implementation 'com.raygun:raygun4android:x.y.z'

implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'

debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.12'
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.raygun.raygun4androidsample.sample
package com.raygun.raygun4android.sample

import android.support.test.InstrumentationRegistry
import android.support.test.runner.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith
Expand All @@ -19,6 +19,6 @@ class ExampleInstrumentedTest {
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getTargetContext()
assertEquals("com.raygun.raygun4androidsample.sample", appContext.packageName)
assertEquals("com.raygun.raygun4android.sample", appContext.packageName)
}
}
4 changes: 4 additions & 0 deletions app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
</manifest>
3 changes: 1 addition & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<application
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<activity android:name=".MainActivity" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.raygun.raygun4androidsample.sample
package com.raygun.raygun4android.sample

import android.app.Application
import android.support.v7.app.AppCompatActivity
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import com.raygun.raygun4android.RaygunClient
Expand Down Expand Up @@ -91,8 +91,8 @@ class MainActivity : AppCompatActivity() {
}


textViewAppVersion.text = "App ${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE} ${BuildConfig.BUILD_TYPE})"
textViewProviderVersion.text = "Provider ${com.raygun.raygun4android.BuildConfig.VERSION_NAME} (${com.raygun.raygun4android.BuildConfig.VERSION_CODE} ${BuildConfig.BUILD_TYPE})"
textViewAppVersion.text = getString(R.string.app_version_text, BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE, BuildConfig.BUILD_TYPE)
textViewProviderVersion.text = getString(R.string.provider_version_text, BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE, BuildConfig.BUILD_TYPE)
TheRealAgentK marked this conversation as resolved.
Show resolved Hide resolved

RaygunClient.recordBreadcrumb("I'm here in Main Activity")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.raygun.raygun4androidsample.sample
package com.raygun.raygun4android.sample

import android.util.Log
import com.raygun.raygun4android.CrashReportingOnBeforeSend
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.raygun.raygun4androidsample.sample
package com.raygun.raygun4android.sample

import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import androidx.appcompat.app.AppCompatActivity
import android.util.Log
import android.widget.Button
import android.widget.TextView
Expand Down Expand Up @@ -76,8 +76,8 @@ class SecondActivity : AppCompatActivity() {
RaygunClient.setUser(user)
}

textViewAppVersion.text = "App ${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE} ${BuildConfig.BUILD_TYPE})"
textViewProviderVersion.text = "Provider ${com.raygun.raygun4android.BuildConfig.VERSION_NAME} (${com.raygun.raygun4android.BuildConfig.VERSION_CODE} ${BuildConfig.BUILD_TYPE})"
textViewAppVersion.text = getString(R.string.app_version_text, BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE, BuildConfig.BUILD_TYPE)
textViewProviderVersion.text = getString(R.string.provider_version_text, BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE, BuildConfig.BUILD_TYPE)

RaygunClient.clearBreadcrumbs()

Expand Down
Loading