Skip to content

[various] Scrubs pre-SDK-21 Android code #9112

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

Merged
merged 9 commits into from
Apr 19, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ public void setDescriptionWhileRecording_errorsWhenUnsupported() {
camera.mediaRecorder = mockMediaRecorder;
camera.recordingVideo = true;
camera.videoRenderer = mockVideoRenderer;
SdkCapabilityChecker.SDK_VERSION = Build.VERSION_CODES.LOLLIPOP;
SdkCapabilityChecker.SDK_VERSION = Build.VERSION_CODES.N;

final CameraProperties newCameraProperties = mock(CameraProperties.class);
assertThrows(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ tasks.register("clean", Delete) {
gradle.projectsEvaluated {
project(":camera_android") {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:all" << "-Werror"
// Ignore classfile due to https://issuetracker.google.com/issues/342067844
options.compilerArgs << "-Xlint:all" << "-Werror" << "-Xlint:-classfile"
}
}
}
4 changes: 4 additions & 0 deletions packages/espresso/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.4.0+7

* Removes obsolete code related to supporting SDK <21.

## 0.4.0+6

* Updates compileSdk 34 to flutter.compileSdkVersion.
Expand Down
2 changes: 1 addition & 1 deletion packages/espresso/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Provides bindings for Espresso tests of Flutter Android apps.

| | Android |
|-------------|---------|
| **Support** | SDK 16+ |
| **Support** | SDK 21+ |

## Installation

Expand Down
2 changes: 1 addition & 1 deletion packages/espresso/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ android {
compileSdk = flutter.compileSdkVersion

defaultConfig {
minSdkVersion 19
minSdkVersion 21
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

Expand Down
2 changes: 1 addition & 1 deletion packages/espresso/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Java classes for testing Flutter apps using Espresso.
Allows driving Flutter widgets from a native Espresso test.
repository: https://github.com/flutter/packages/tree/main/packages/espresso
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+espresso%22
version: 0.4.0+6
version: 0.4.0+7

environment:
sdk: ^3.6.0
Expand Down
1 change: 1 addition & 0 deletions packages/file_selector/file_selector/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## NEXT

* Updates README to indicate that Andoid SDK <21 is no longer supported.
* Updates minimum supported SDK version to Flutter 3.22/Dart 3.4.

## 1.0.3
Expand Down
6 changes: 2 additions & 4 deletions packages/file_selector/file_selector/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ A Flutter plugin that manages files and interactions with file dialogs.

| | Android | iOS | Linux | macOS | Web | Windows |
|-------------|---------|---------|-------|--------|-----|-------------|
| **Support** | SDK 19+ | iOS 12+ | Any | 10.14+ | Any | Windows 10+ |
| **Support** | SDK 21+ | iOS 12+ | Any | 10.14+ | Any | Windows 10+ |

## Setup

Expand Down Expand Up @@ -114,9 +114,7 @@ pass different `XTypeGroup`s based on `Platform`.
| Choose a single file | Pick a file/image | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| Choose multiple files | Pick multiple files/images | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
| Choose a save location | Pick a directory to save a file in | ❌ | ❌ | ✔️ | ✔️ | ✔️ | ❌ |
| Choose a directory | Pick a directory and get its path | ✔️† | ❌ | ✔️ | ✔️ | ✔️ | ❌ |

† Choosing a directory is no supported on versions of Android before SDK 21 (Lollipop).
| Choose a directory | Pick a directory and get its path | ✔️ | ❌ | ✔️ | ✔️ | ✔️ | ❌ |

[example]:./example
[entitlement]: https://docs.flutter.dev/desktop#entitlements-and-the-app-sandbox
4 changes: 4 additions & 0 deletions packages/file_selector/file_selector_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.5.1+14

* Removes obsolete code related to supporting SDK <21.

## 0.5.1+13

* Updates compileSdk 34 to flutter.compileSdkVersion.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ android {
}

defaultConfig {
minSdkVersion 19
minSdkVersion 21
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import static dev.flutter.packages.file_selector_android.FileUtils.FILE_SELECTOR_EXCEPTION_PLACEHOLDER_PATH;

import android.annotation.TargetApi;
import android.app.Activity;
import android.content.ClipData;
import android.content.ContentResolver;
Expand Down Expand Up @@ -193,17 +192,9 @@ public void onResult(int resultCode, @Nullable Intent data) {
}

@Override
@TargetApi(21)
public void getDirectoryPath(
@Nullable String initialDirectory,
@NonNull GeneratedFileSelectorApi.NullableResult<String> result) {
if (!sdkChecker.sdkIsAtLeast(android.os.Build.VERSION_CODES.LOLLIPOP)) {
result.error(
new UnsupportedOperationException(
"Selecting a directory is only supported on versions >= 21"));
return;
}

final Intent intent = objectFactory.newIntent(Intent.ACTION_OPEN_DOCUMENT_TREE);
trySetInitialDirectory(intent, initialDirectory);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ public void getDirectoryPathReturnsSuccessfully() {
new FileSelectorApiImpl(
mockActivityBinding,
mockObjectFactory,
(version) -> Build.VERSION_CODES.LOLLIPOP >= version);
(version) -> Build.VERSION.SDK_INT >= version);

final GeneratedFileSelectorApi.NullableResult mockResult =
mock(GeneratedFileSelectorApi.NullableResult.class);
Expand All @@ -465,20 +465,4 @@ public void getDirectoryPathReturnsSuccessfully() {
}
}
}

@Test
public void getDirectoryPath_errorsForUnsupportedVersion() {
final FileSelectorApiImpl fileSelectorApi =
new FileSelectorApiImpl(
mockActivityBinding,
mockObjectFactory,
(version) -> Build.VERSION_CODES.KITKAT >= version);

@SuppressWarnings("unchecked")
final GeneratedFileSelectorApi.NullableResult<String> mockResult =
mock(GeneratedFileSelectorApi.NullableResult.class);
fileSelectorApi.getDirectoryPath(null, mockResult);

verify(mockResult).error(any());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ tasks.register("clean", Delete) {
gradle.projectsEvaluated {
project(":file_selector_android") {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:all" << "-Werror"
// Ignore classfile due to https://issuetracker.google.com/issues/342067844
options.compilerArgs << "-Xlint:all" << "-Werror" << "-Xlint:-classfile"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: file_selector_android
description: Android implementation of the file_selector package.
repository: https://github.com/flutter/packages/tree/main/packages/file_selector/file_selector_android
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+file_selector%22
version: 0.5.1+13
version: 0.5.1+14

environment:
sdk: ^3.6.0
Expand Down
4 changes: 4 additions & 0 deletions packages/flutter_plugin_android_lifecycle/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.0.28

* Removes obsolete code related to supporting SDK <21.

## 2.0.27

* Bumps flutter supported version to 3.27 and use flutter.compileSdkVersion.
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter_plugin_android_lifecycle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ major version of the Android `Lifecycle` API they expect.

| | Android |
|-------------|---------|
| **Support** | SDK 16+ |
| **Support** | SDK 21+ |

## Example

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ android {
compileSdk = flutter.compileSdkVersion

defaultConfig {
minSdkVersion 19
minSdkVersion 21
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'proguard.txt'
}
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter_plugin_android_lifecycle/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: flutter_plugin_android_lifecycle
description: Flutter plugin for accessing an Android Lifecycle within other plugins.
repository: https://github.com/flutter/packages/tree/main/packages/flutter_plugin_android_lifecycle
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+flutter_plugin_android_lifecycle%22
version: 2.0.27
version: 2.0.28

environment:
sdk: ^3.6.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## NEXT

* Updates README to indicate that Andoid SDK <21 is no longer supported.

## 2.12.1

* Fixes typo in README.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ A Flutter plugin that provides a [Google Maps](https://developers.google.com/map

| | Android | iOS | Web |
|-------------|---------|---------|----------------------------------|
| **Support** | SDK 20+ | iOS 14+ | Same as [Flutter's][web-support] |
| **Support** | SDK 21+ | iOS 14+ | Same as [Flutter's][web-support] |

[web-support]: https://docs.flutter.dev/reference/supported-platforms

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.16.1

* Removes obsolete code related to supporting SDK <21.

## 2.16.0

* Adds support for animating the camera with a duration.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ android {
compileSdk = flutter.compileSdkVersion

defaultConfig {
minSdkVersion 20
minSdkVersion 21
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
lintOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import android.content.Context;
import android.content.res.AssetManager;
import android.graphics.Bitmap;
import android.os.Build;
import androidx.test.core.app.ApplicationProvider;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.model.CameraPosition;
Expand All @@ -41,10 +40,8 @@
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;

@RunWith(RobolectricTestRunner.class)
@Config(minSdk = Build.VERSION_CODES.LOLLIPOP)
public class ClusterManagersControllerTest {
private Context context;
private MapsCallbackApi flutterApi;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import static org.mockito.Mockito.when;

import android.content.res.AssetManager;
import android.os.Build;
import android.util.Base64;
import androidx.annotation.NonNull;
import com.google.android.gms.maps.model.BitmapDescriptor;
Expand All @@ -49,10 +48,8 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;

@RunWith(RobolectricTestRunner.class)
@Config(minSdk = Build.VERSION_CODES.LOLLIPOP)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the @config annotation should stay and you should use the new minimum.

minSdk= is supposed to run the tests for every version of android after that version.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe I misunderstood @Config. Does it restrict the APIs that this test can be run under, or does it cause the test to be run with multiple API levels? I thought it was the former.

If it's the latter, I'm skeptical we want this. We don't do this pretty much anywhere else in the repo, and I can't think of any reason we would want to multi-run things for the maps SDK in particular, since the SDK isn't system-API-level based.

Copy link
Contributor

Choose a reason for hiding this comment

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

My understanding is it is the latter. Here is some documentation that I think supports that conclusion. https://robolectric.org/configuring/#configure-sdk-level. If you wanted to run on a specific set then you would use sdk = .

Looking through ConvertTest I agree but there are other places in packages where it does make sense to run with a minSdk or other broader android versions set. Primarily to make sure branching logic based on android api gets exercised.

Update: a spot check of all of these google maps test entries shows minimal value in multi api level tests because they do not branch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll go ahead and remove them then; the fact that we only do this for these tests, and these tests don't seem like they benefit, makes me think that adding it was a result of a misunderstanding like mine.

public class ConvertTest {
@Mock private AssetManager assetManager;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import static org.mockito.Mockito.when;

import android.content.Context;
import android.os.Build;
import androidx.activity.ComponentActivity;
import androidx.test.core.app.ApplicationProvider;
import com.google.android.gms.maps.CameraUpdate;
Expand All @@ -41,10 +40,8 @@
import org.mockito.MockitoAnnotations;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;

@RunWith(RobolectricTestRunner.class)
@Config(minSdk = Build.VERSION_CODES.LOLLIPOP)
Copy link
Contributor

Choose a reason for hiding this comment

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

same here.

public class GoogleMapControllerTest {

private Context context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import static org.mockito.Mockito.verify;

import android.content.Context;
import android.os.Build;
import androidx.test.core.app.ApplicationProvider;
import com.google.android.gms.maps.MapsInitializer.Renderer;
import io.flutter.plugin.common.BinaryMessenger;
Expand All @@ -23,10 +22,8 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;

@RunWith(RobolectricTestRunner.class)
@Config(minSdk = Build.VERSION_CODES.LOLLIPOP)
Copy link
Contributor

Choose a reason for hiding this comment

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

and here. Not marking any more but if we agree on @config staying then update all instances.

public class GoogleMapInitializerTest {
private GoogleMapInitializer googleMapInitializer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import android.content.Context;
import android.content.res.AssetManager;
import android.os.Build;
import android.util.Base64;
import androidx.annotation.NonNull;
import androidx.test.core.app.ApplicationProvider;
Expand All @@ -31,10 +30,8 @@
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;

@RunWith(RobolectricTestRunner.class)
@Config(minSdk = Build.VERSION_CODES.LOLLIPOP)
public class GroundOverlaysControllerTest {
@Mock private BitmapDescriptorFactoryWrapper bitmapDescriptorFactoryWrapper;
@Mock private BitmapDescriptor mockBitmapDescriptor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.when;

import android.os.Build;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.model.TileOverlay;
import com.google.android.gms.maps.model.TileOverlayOptions;
Expand All @@ -30,10 +29,8 @@
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;

@RunWith(RobolectricTestRunner.class)
@Config(minSdk = Build.VERSION_CODES.LOLLIPOP)
public class HeatmapsControllerTest {
private HeatmapsController controller;
private GoogleMap googleMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import android.content.Context;
import android.content.res.AssetManager;
import android.graphics.Bitmap;
import android.os.Build;
import androidx.test.core.app.ApplicationProvider;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.model.LatLng;
Expand All @@ -36,10 +35,8 @@
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;

@RunWith(RobolectricTestRunner.class)
@Config(minSdk = Build.VERSION_CODES.LOLLIPOP)
public class MarkersControllerTest {
private Context context;
private MapsCallbackApi flutterApi;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: google_maps_flutter_android
description: Android implementation of the google_maps_flutter plugin.
repository: https://github.com/flutter/packages/tree/main/packages/google_maps_flutter/google_maps_flutter_android
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22
version: 2.16.0
version: 2.16.1

environment:
sdk: ^3.6.0
Expand Down
4 changes: 4 additions & 0 deletions packages/google_sign_in/google_sign_in/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## NEXT

* Updates README to indicate that Andoid SDK <21 is no longer supported.

## 6.3.0

* Adds a sign-in field to allow Android clients to explicitly specify an account name. This
Expand Down
Loading