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

New sample with min api level #2117

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 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
25 changes: 13 additions & 12 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,19 @@ apiValidation {
ignoredProjects.addAll(
listOf(
"sentry-samples-android",
"sentry-samples-console",
"sentry-samples-jul",
"sentry-samples-log4j2",
"sentry-samples-logback",
"sentry-samples-openfeign",
"sentry-samples-servlet",
"sentry-samples-spring",
"sentry-samples-spring-boot",
"sentry-samples-spring-boot-webflux",
"sentry-samples-netflix-dgs",
"sentry-uitest-android",
"sentry-uitest-android-benchmark",
"sentry-samples-android-minsdk",
// "sentry-samples-console",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert before merging

// "sentry-samples-jul",
// "sentry-samples-log4j2",
// "sentry-samples-logback",
// "sentry-samples-openfeign",
// "sentry-samples-servlet",
// "sentry-samples-spring",
// "sentry-samples-spring-boot",
// "sentry-samples-spring-boot-webflux",
// "sentry-samples-netflix-dgs",
// "sentry-uitest-android",
// "sentry-uitest-android-benchmark",
)
)
}
Expand Down
3 changes: 2 additions & 1 deletion buildSrc/src/main/java/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ object Config {
val kotlinCompatibleLanguageVersion = "1.4"

object BuildPlugins {
val androidGradle = "com.android.tools.build:gradle:7.2.0"
val androidGradle = "com.android.tools.build:gradle:7.2.1"
val kotlinGradlePlugin = "gradle-plugin"
val buildConfig = "com.github.gmazzo.buildconfig"
val buildConfigVersion = "3.0.3"
Expand Down Expand Up @@ -154,6 +154,7 @@ object Config {
val binaryCompatibilityValidatorVersion = "0.8.0"
val binaryCompatibilityValidatorPlugin = "org.jetbrains.kotlinx:binary-compatibility-validator:$binaryCompatibilityValidatorVersion"
val binaryCompatibilityValidator = "org.jetbrains.kotlinx.binary-compatibility-validator"
val androidLint = "com.android.lint"
}

object Sentry {
Expand Down
3 changes: 2 additions & 1 deletion sentry-android-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ android {

// We run a full lint analysis as build part in CI, so skip vital checks for assemble tasks.
checkReleaseBuilds = false
disable += "LogNotTimber"
checkAllWarnings = true
disable.addAll(listOf("TrulyRandom", "SyntheticAccessor", "LogConditional", "UnknownNullness", "LogNotTimber"))
}

// needed because of Kotlin 1.4.x
Expand Down
2 changes: 2 additions & 0 deletions sentry-android-fragment/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ android {

// We run a full lint analysis as build part in CI, so skip vital checks for assemble tasks.
checkReleaseBuilds = false
checkAllWarnings = true
disable.addAll(listOf("TrulyRandom", "SyntheticAccessor", "InvalidPackage"))
}

variantFilter {
Expand Down
2 changes: 2 additions & 0 deletions sentry-android-ndk/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ android {

// We run a full lint analysis as build part in CI, so skip vital checks for assemble tasks.
checkReleaseBuilds = false
checkAllWarnings = true
disable.addAll(listOf("TrulyRandom", "SyntheticAccessor"))
}

nativeBundleExport {
Expand Down
2 changes: 2 additions & 0 deletions sentry-android-okhttp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ android {

// We run a full lint analysis as build part in CI, so skip vital checks for assemble tasks.
checkReleaseBuilds = false
checkAllWarnings = true
disable.addAll(listOf("TrulyRandom", "SyntheticAccessor"))
}

variantFilter {
Expand Down
2 changes: 2 additions & 0 deletions sentry-android-timber/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ android {

// We run a full lint analysis as build part in CI, so skip vital checks for assemble tasks.
checkReleaseBuilds = false
checkAllWarnings = true
disable.addAll(listOf("TrulyRandom", "SyntheticAccessor"))
}

variantFilter {
Expand Down
10 changes: 10 additions & 0 deletions sentry-android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ android {
ignore = true
}
}

lint {
warningsAsErrors = true
checkDependencies = true

// We run a full lint analysis as build part in CI, so skip vital checks for assemble tasks.
checkReleaseBuilds = false
checkAllWarnings = true
disable.addAll(listOf("TrulyRandom", "SyntheticAccessor"))
}
}

dependencies {
Expand Down
12 changes: 12 additions & 0 deletions sentry-apollo/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import com.android.build.api.dsl.Lint
import net.ltgt.gradle.errorprone.errorprone
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

Expand All @@ -8,6 +9,7 @@ plugins {
id(Config.QualityPlugins.errorProne)
id(Config.QualityPlugins.gradleVersions)
id(Config.BuildPlugins.buildConfig) version Config.BuildPlugins.buildConfigVersion
id(Config.QualityPlugins.androidLint)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Java projects can add the Android lint but I could not find a way to configure it using lint {} cus android {} does not exist.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apollo is also available for non Android, not sure how we would add it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adinauer what do you mean? This is the Apollo module and I'm adding the lint to it, so it's alright.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I was trying to say that we probably can't just add the android plugin to it to gain android {} in there as this can also be used by non Android applications.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah gotcha, that's not the problem, lint is already being applied to this module as a non-Android project, and it's being executed, I just can't change the default options apparently.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we simply run grep on the logs instead and check for minApi warnings?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But which logs do you want to run grep on? You need to be able to run lint first :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it works but we can't customize it to fail the build for minSdk violations.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the Linter runs already, but it does not check for newApi.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/open-toast/gummy-bears
This can help
have you used/tried this @romtsn @markushi ?

}

configure<JavaPluginExtension> {
Expand All @@ -20,6 +22,16 @@ tasks.withType<KotlinCompile>().configureEach {
kotlinOptions.languageVersion = Config.kotlinCompatibleLanguageVersion
}

configure<Lint> {
warningsAsErrors = true
checkDependencies = true

// We run a full lint analysis as build part in CI, so skip vital checks for assemble tasks.
checkReleaseBuilds = false
disable.addAll(listOf("TrulyRandom"))
checkAllWarnings = true
}

dependencies {
api(projects.sentry)
api(projects.sentryKotlinExtensions)
Expand Down
1 change: 1 addition & 0 deletions sentry-samples/sentry-samples-android-minsdk/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
90 changes: 90 additions & 0 deletions sentry-samples/sentry-samples-android-minsdk/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
plugins {
id("com.android.application")
kotlin("android")
}

android {
compileSdk = Config.Android.compileSdkVersion

defaultConfig {
applicationId = "io.sentry.samples.android.minsdk"
minSdk = Config.Android.minSdkVersion
targetSdk = Config.Android.targetSdkVersion
versionCode = 2
versionName = "1.1.0"
}

buildFeatures {
// Determines whether to support View Binding.
// Note that the viewBinding.enabled property is now deprecated.
viewBinding = true
}

dependenciesInfo {
// Disables dependency metadata when building APKs.
includeInApk = false
// Disables dependency metadata when building Android App Bundles.
includeInBundle = false
}

signingConfigs {
getByName("debug") {
storeFile = rootProject.file("debug.keystore")
storePassword = "android"
keyAlias = "androiddebugkey"
keyPassword = "android"
}
}

buildTypes {
getByName("debug") {
addManifestPlaceholders(
mapOf(
"sentryDebug" to true
)
)
}
getByName("release") {
isMinifyEnabled = true
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
signingConfig = signingConfigs.getByName("debug") // to be able to run release mode
isShrinkResources = true

addManifestPlaceholders(
mapOf(
"sentryDebug" to false
)
)
}
}

kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}

variantFilter {
if (Config.Android.shouldSkipDebugVariant(buildType.name)) {
ignore = true
}
}

lint {
warningsAsErrors = true
checkDependencies = true

// We run a full lint analysis as build part in CI, so skip vital checks for assemble tasks.
checkReleaseBuilds = false
disable += "TrulyRandom"
}
}

dependencies {
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))

implementation(projects.sentryAndroid)
implementation(projects.sentryAndroidFragment)
implementation(projects.sentryAndroidTimber)
implementation(projects.sentryApollo)
Comment on lines +85 to +88
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So all projects with lower API is here


implementation(Config.Libs.appCompat)
}
35 changes: 35 additions & 0 deletions sentry-samples/sentry-samples-android-minsdk/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# To ensure that stack traces is unambiguous
# https://developer.android.com/studio/build/shrink-code#decode-stack-trace
-keepattributes LineNumberTable,SourceFile


# For native methods, see http://proguard.sourceforge.net/manual/examples.html#native
-keepclasseswithmembernames,includedescriptorclasses class * {
native <methods>;
}

# Please add these rules to your existing keep rules in order to suppress warnings.
# This is generated automatically by the Android Gradle plugin.
-dontwarn org.bouncycastle.jsse.BCSSLParameters
-dontwarn org.bouncycastle.jsse.BCSSLSocket
-dontwarn org.bouncycastle.jsse.provider.BouncyCastleJsseProvider
-dontwarn org.conscrypt.Conscrypt$Version
-dontwarn org.conscrypt.Conscrypt
-dontwarn org.conscrypt.ConscryptHostnameVerifier
-dontwarn org.openjsse.javax.net.ssl.SSLParameters
-dontwarn org.openjsse.javax.net.ssl.SSLSocket
-dontwarn org.openjsse.net.ssl.OpenJSSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="io.sentry.samples.android.minsdk">

<!-- extra recommended permission, we'd be able to check network status-->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<!-- add extra permission (optional) -->
<!-- extra recommended permission, we'd be able to collect device ringing breadcrumbs (PhoneStateBreadcrumbsIntegration) -->
<uses-permission android:name="android.permission.READ_PHONE_STATE" />

<!-- if your minSdkVersion < 16, this would make usable on minSdkVersion >= 14-->
<uses-sdk
tools:overrideLibrary="io.sentry.android"/>

<application
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning, UnusedAttribute">

<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

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

<!-- NOTE: Replace the test DSN below with YOUR OWN DSN to see the events from this app in your Sentry project/dashboard-->
<meta-data android:name="io.sentry.dsn" android:value="https://[email protected]/5428559" />

<!-- how to enable Sentry's debug mode-->
<meta-data android:name="io.sentry.debug" android:value="${sentryDebug}" />

</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package io.sentry.samples.android.minsdk;

import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import io.sentry.samples.android.minsdk.databinding.ActivityMainBinding;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

final ActivityMainBinding binding = ActivityMainBinding.inflate(getLayoutInflater());

setContentView(binding.getRoot());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillType="evenOdd"
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
android:strokeWidth="1"
android:strokeColor="#00000000">
<aapt:attr name="android:fillColor">
<gradient
android:endX="78.5885"
android:endY="90.9159"
android:startX="48.7653"
android:startY="61.0927"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>
Loading