Skip to content

Commit f11d784

Browse files
authored
Bump Android minSdkVersion to 21 (#3852)
* Bump Android minSdkVersion to 21 everywhere * Update Changelog * Address PR feedback * Fix failing tests
1 parent 254787a commit f11d784

File tree

29 files changed

+54
-231
lines changed

29 files changed

+54
-231
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### Breaking Changes
66

7+
- The Android minSdk level for all Android modules is now 21 ([#3852](https://github.com/getsentry/sentry-java/pull/3852))
78
- The minSdk level for sentry-android-ndk changed from 19 to 21 ([#3851](https://github.com/getsentry/sentry-java/pull/3851))
89

910
### Features

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,24 @@ Sentry SDK for Java and Android
1818

1919
| Packages | Maven Central | Minimum Android API Version |
2020
|-----------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| ------- |
21-
| sentry-android | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-android/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-android) | 19 |
22-
| sentry-android-core | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-android-core/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-android-core) | 19 |
21+
| sentry-android | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-android/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-android) | 21 |
22+
| sentry-android-core | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-android-core/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-android-core) | 21 |
2323
| sentry-android-ndk | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-android-ndk/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-android-ndk) | 21 |
24-
| sentry-android-timber | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-android-timber/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-android-timber) | 19 |
25-
| sentry-android-fragment | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-android-fragment/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-android-fragment) | 19 |
26-
| sentry-android-navigation | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-android-navigation/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-android-navigation) | 19 |
27-
| sentry-android-sqlite | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-android-sqlite/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-android-sqlite) | 19 |
24+
| sentry-android-timber | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-android-timber/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-android-timber) | 21 |
25+
| sentry-android-fragment | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-android-fragment/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-android-fragment) | 21 |
26+
| sentry-android-navigation | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-android-navigation/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-android-navigation) | 21 |
27+
| sentry-android-sqlite | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-android-sqlite/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-android-sqlite) | 21 |
2828
| sentry-android-replay | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-android-replay/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-android-replay) | 26 |
2929
| sentry-compose-android | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-compose-android/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-compose-android) | 21 |
3030
| sentry-compose-desktop | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-compose-desktop/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-compose-desktop) |
3131
| sentry-compose | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-compose/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-compose) |
3232
| sentry-apache-http-client-5 | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-apache-http-client-5/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-apache-http-client-5) |
33-
| sentry | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry) | 19 |
33+
| sentry | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry) | 21 |
3434
| sentry-jul | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-jul/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-jul) |
3535
| sentry-jdbc | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-jdbc/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-jdbc) |
36-
| sentry-apollo | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-apollo/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-apollo) | 19 |
37-
| sentry-apollo-3 | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-apollo-3/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-apollo-3) | 19 |
38-
| sentry-kotlin-extensions | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-kotlin-extensions/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-kotlin-extensions) | 19 |
36+
| sentry-apollo | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-apollo/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-apollo) | 21 |
37+
| sentry-apollo-3 | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-apollo-3/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-apollo-3) | 21 |
38+
| sentry-kotlin-extensions | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-kotlin-extensions/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-kotlin-extensions) | 21 |
3939
| sentry-servlet | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-servlet/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-servlet) | |
4040
| sentry-servlet-jakarta | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-servlet-jakarta/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-servlet-jakarta) | |
4141
| sentry-spring-boot | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-spring-boot/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.sentry/sentry-spring-boot) |

buildSrc/src/main/java/Config.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,7 @@ object Config {
3333
object Android {
3434
private val sdkVersion = 34
3535

36-
val minSdkVersion = 19
37-
val minSdkVersionOkHttp = 21
38-
val minSdkVersionReplay = 19
39-
val minSdkVersionNdk = 21
40-
val minSdkVersionCompose = 21
36+
val minSdkVersion = 21
4137
val targetSdkVersion = sdkVersion
4238
val compileSdkVersion = sdkVersion
4339

sentry-android-core/api/sentry-android-core.api

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public final class io/sentry/android/core/ActivityLifecycleIntegration : android
3737
}
3838

3939
public final class io/sentry/android/core/AndroidCpuCollector : io/sentry/IPerformanceSnapshotCollector {
40-
public fun <init> (Lio/sentry/ILogger;Lio/sentry/android/core/BuildInfoProvider;)V
40+
public fun <init> (Lio/sentry/ILogger;)V
4141
public fun collect (Lio/sentry/PerformanceCollectionData;)V
4242
public fun setup ()V
4343
}
@@ -64,7 +64,7 @@ public class io/sentry/android/core/AndroidMemoryCollector : io/sentry/IPerforma
6464

6565
public class io/sentry/android/core/AndroidProfiler {
6666
protected final field lock Lio/sentry/util/AutoClosableReentrantLock;
67-
public fun <init> (Ljava/lang/String;ILio/sentry/android/core/internal/util/SentryFrameMetricsCollector;Lio/sentry/ISentryExecutorService;Lio/sentry/ILogger;Lio/sentry/android/core/BuildInfoProvider;)V
67+
public fun <init> (Ljava/lang/String;ILio/sentry/android/core/internal/util/SentryFrameMetricsCollector;Lio/sentry/ISentryExecutorService;Lio/sentry/ILogger;)V
6868
public fun close ()V
6969
public fun endAndCollect (ZLjava/util/List;)Lio/sentry/android/core/AndroidProfiler$ProfileEndData;
7070
public fun start ()Lio/sentry/android/core/AndroidProfiler$ProfileStartData;

sentry-android-core/src/main/java/io/sentry/android/core/AndroidCpuCollector.java

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package io.sentry.android.core;
22

3-
import android.annotation.SuppressLint;
4-
import android.os.Build;
53
import android.os.SystemClock;
64
import android.system.Os;
75
import android.system.OsConstants;
@@ -41,35 +39,25 @@ public final class AndroidCpuCollector implements IPerformanceSnapshotCollector
4139
private final @NotNull File selfStat = new File("/proc/self/stat");
4240

4341
private final @NotNull ILogger logger;
44-
private final @NotNull BuildInfoProvider buildInfoProvider;
4542
private boolean isEnabled = false;
4643
private final @NotNull Pattern newLinePattern = Pattern.compile("[\n\t\r ]");
4744

48-
public AndroidCpuCollector(
49-
final @NotNull ILogger logger, final @NotNull BuildInfoProvider buildInfoProvider) {
45+
public AndroidCpuCollector(final @NotNull ILogger logger) {
5046
this.logger = Objects.requireNonNull(logger, "Logger is required.");
51-
this.buildInfoProvider =
52-
Objects.requireNonNull(buildInfoProvider, "BuildInfoProvider is required.");
5347
}
5448

55-
@SuppressLint("NewApi")
5649
@Override
5750
public void setup() {
58-
if (buildInfoProvider.getSdkInfoVersion() < Build.VERSION_CODES.LOLLIPOP) {
59-
isEnabled = false;
60-
return;
61-
}
6251
isEnabled = true;
6352
clockSpeedHz = Os.sysconf(OsConstants._SC_CLK_TCK);
6453
numCores = Os.sysconf(OsConstants._SC_NPROCESSORS_CONF);
6554
nanosecondsPerClockTick = NANOSECOND_PER_SECOND / (double) clockSpeedHz;
6655
lastCpuNanos = readTotalCpuNanos();
6756
}
6857

69-
@SuppressLint("NewApi")
7058
@Override
7159
public void collect(final @NotNull PerformanceCollectionData performanceCollectionData) {
72-
if (buildInfoProvider.getSdkInfoVersion() < Build.VERSION_CODES.LOLLIPOP || !isEnabled) {
60+
if (!isEnabled) {
7361
return;
7462
}
7563
final long nowNanos = SystemClock.elapsedRealtimeNanos();

sentry-android-core/src/main/java/io/sentry/android/core/AndroidOptionsInitializer.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,7 @@ static void initializeIntegrationsAndProcessors(
212212
options.setThreadChecker(AndroidThreadChecker.getInstance());
213213
if (options.getPerformanceCollectors().isEmpty()) {
214214
options.addPerformanceCollector(new AndroidMemoryCollector());
215-
options.addPerformanceCollector(
216-
new AndroidCpuCollector(options.getLogger(), buildInfoProvider));
215+
options.addPerformanceCollector(new AndroidCpuCollector(options.getLogger()));
217216

218217
if (options.isEnablePerformanceV2()) {
219218
options.addPerformanceCollector(

sentry-android-core/src/main/java/io/sentry/android/core/AndroidProfiler.java

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package io.sentry.android.core;
22

33
import android.annotation.SuppressLint;
4-
import android.os.Build;
54
import android.os.Debug;
65
import android.os.Process;
76
import android.os.SystemClock;
@@ -94,7 +93,6 @@ public ProfileEndData(
9493
private final @NotNull ArrayDeque<ProfileMeasurementValue> frozenFrameRenderMeasurements =
9594
new ArrayDeque<>();
9695
private final @NotNull Map<String, ProfileMeasurement> measurementsMap = new HashMap<>();
97-
private final @NotNull BuildInfoProvider buildInfoProvider;
9896
private final @NotNull ISentryExecutorService executorService;
9997
private final @NotNull ILogger logger;
10098
private boolean isRunning = false;
@@ -105,17 +103,14 @@ public AndroidProfiler(
105103
final int intervalUs,
106104
final @NotNull SentryFrameMetricsCollector frameMetricsCollector,
107105
final @NotNull ISentryExecutorService executorService,
108-
final @NotNull ILogger logger,
109-
final @NotNull BuildInfoProvider buildInfoProvider) {
106+
final @NotNull ILogger logger) {
110107
this.traceFilesDir =
111108
new File(Objects.requireNonNull(tracesFilesDirPath, "TracesFilesDirPath is required"));
112109
this.intervalUs = intervalUs;
113110
this.logger = Objects.requireNonNull(logger, "Logger is required");
114111
this.executorService = Objects.requireNonNull(executorService, "ExecutorService is required.");
115112
this.frameMetricsCollector =
116113
Objects.requireNonNull(frameMetricsCollector, "SentryFrameMetricsCollector is required");
117-
this.buildInfoProvider =
118-
Objects.requireNonNull(buildInfoProvider, "The BuildInfoProvider is required.");
119114
}
120115

121116
@SuppressLint("NewApi")
@@ -133,9 +128,6 @@ public AndroidProfiler(
133128
return null;
134129
}
135130

136-
// and SystemClock.elapsedRealtimeNanos() since Jelly Bean
137-
if (buildInfoProvider.getSdkInfoVersion() < Build.VERSION_CODES.LOLLIPOP) return null;
138-
139131
// We create a file with a uuid name, so no need to check if it already exists
140132
traceFile = new File(traceFilesDir, UUID.randomUUID() + ".trace");
141133

@@ -232,9 +224,6 @@ public void onFrameMetricCollected(
232224
return null;
233225
}
234226

235-
// and SystemClock.elapsedRealtimeNanos() since Jelly Bean
236-
if (buildInfoProvider.getSdkInfoVersion() < Build.VERSION_CODES.LOLLIPOP) return null;
237-
238227
try {
239228
// If there is any problem with the file this method could throw, but the start is also
240229
// wrapped, so this should never happen (except for tests, where this is the only method
@@ -304,12 +293,6 @@ public void close() {
304293
private void putPerformanceCollectionDataInMeasurements(
305294
final @Nullable List<PerformanceCollectionData> performanceCollectionData) {
306295

307-
// onTransactionStart() is only available since Lollipop
308-
// and SystemClock.elapsedRealtimeNanos() since Jelly Bean
309-
if (buildInfoProvider.getSdkInfoVersion() < Build.VERSION_CODES.LOLLIPOP) {
310-
return;
311-
}
312-
313296
// This difference is required, since the PerformanceCollectionData timestamps are expressed in
314297
// terms of System.currentTimeMillis() and measurements timestamps require the nanoseconds since
315298
// the beginning, expressed with SystemClock.elapsedRealtimeNanos()

sentry-android-core/src/main/java/io/sentry/android/core/AndroidTransactionProfiler.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,7 @@ private void init() {
121121
(int) SECONDS.toMicros(1) / profilingTracesHz,
122122
frameMetricsCollector,
123123
executorService,
124-
logger,
125-
buildInfoProvider);
124+
logger);
126125
}
127126

128127
@Override

sentry-android-core/src/main/java/io/sentry/android/core/AnrV2EventProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ private void setDevice(final @NotNull SentryBaseEvent event) {
641641
device.setFamily(ContextUtils.getFamily(options.getLogger()));
642642
device.setModel(Build.MODEL);
643643
device.setModelId(Build.ID);
644-
device.setArchs(ContextUtils.getArchitectures(buildInfoProvider));
644+
device.setArchs(ContextUtils.getArchitectures());
645645

646646
final ActivityManager.MemoryInfo memInfo =
647647
ContextUtils.getMemInfo(context, options.getLogger());

sentry-android-core/src/main/java/io/sentry/android/core/ContextUtils.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -293,16 +293,8 @@ public static boolean isForegroundImportance() {
293293
return Settings.Global.getString(context.getContentResolver(), "device_name");
294294
}
295295

296-
@SuppressWarnings("deprecation")
297-
@SuppressLint("NewApi") // we're wrapping into if-check with sdk version
298-
static @NotNull String[] getArchitectures(final @NotNull BuildInfoProvider buildInfoProvider) {
299-
final String[] supportedAbis;
300-
if (buildInfoProvider.getSdkInfoVersion() >= Build.VERSION_CODES.LOLLIPOP) {
301-
supportedAbis = Build.SUPPORTED_ABIS;
302-
} else {
303-
supportedAbis = new String[] {Build.CPU_ABI, Build.CPU_ABI2};
304-
}
305-
return supportedAbis;
296+
static @NotNull String[] getArchitectures() {
297+
return Build.SUPPORTED_ABIS;
306298
}
307299

308300
/**

0 commit comments

Comments
 (0)