Skip to content

Commit c2a6d64

Browse files
authored
[cronet_http] ⬇️ Downgrade minSdkVersion to 21 (#1104)
1 parent 661f5d6 commit c2a6d64

File tree

5 files changed

+21
-15
lines changed

5 files changed

+21
-15
lines changed

.github/workflows/cronet.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ jobs:
6262
# - .github/workflows/cronet.yml
6363
# - pkgs/cronet_http/android/build.gradle
6464
# - pkgs/cronet_http/example/android/app/build.gradle
65-
api-level: 28
66-
target: ${{ matrix.package == 'cronet_http_embedded' && 'google_apis' || 'playstore' }}
65+
api-level: 21
66+
arch: x86_64
67+
target: ${{ matrix.package == 'cronet_http_embedded' && 'default' || 'google_apis' }}
6768
profile: pixel
6869
script: cd 'pkgs/${{ matrix.package }}/example' && flutter test --timeout=1200s integration_test/

pkgs/cronet_http/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## 1.0.1-wip
22

33
* Use `package:http_image_provider` in the example application.
4+
* Support Android API 21+.
45

56
## 1.0.0
67

pkgs/cronet_http/android/build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ android {
5050
// - .github/workflows/cronet.yml
5151
// - pkgs/cronet_http/android/build.gradle
5252
// - pkgs/cronet_http/example/android/app/build.gradle
53-
minSdkVersion 28
53+
minSdkVersion 21
5454
}
5555

5656
defaultConfig {
@@ -65,6 +65,5 @@ android {
6565
}
6666

6767
dependencies {
68-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
6968
implementation "com.google.android.gms:play-services-cronet:18.0.1"
7069
}

pkgs/cronet_http/example/android/app/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,11 @@ android {
4444

4545
defaultConfig {
4646
applicationId "io.flutter.cronet_http_example"
47-
// You can update the following values to match your application needs.
48-
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
4947
// api-level/minSdkVersion should be help in sync in:
5048
// - .github/workflows/cronet.yml
5149
// - pkgs/cronet_http/android/build.gradle
5250
// - pkgs/cronet_http/example/android/app/build.gradle
53-
minSdkVersion 28
51+
minSdkVersion 21
5452
targetSdkVersion flutter.targetSdkVersion
5553
versionCode flutterVersionCode.toInteger()
5654
versionName flutterVersionName
@@ -70,7 +68,9 @@ flutter {
7068
}
7169

7270
dependencies {
73-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
71+
// TODO(#1112): org.jetbrains.kotlin:kotlin-bom artifact purpose is to align kotlin stdlib and related code versions.
72+
// This should be removed when https://github.com/flutter/flutter/issues/125062 is fixed.
73+
implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.8.0"))
7474
// ""com.google.android.gms:play-services-cronet" is only present so that
7575
// `jnigen` will work. Applications should not include this line.
7676
implementation "com.google.android.gms:play-services-cronet:18.0.1"

pkgs/cronet_http/tool/prepare_for_embedded.dart

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import 'package:http/http.dart' as http;
2929
import 'package:xml/xml.dart';
3030
import 'package:yaml_edit/yaml_edit.dart';
3131

32+
late final String _scriptName;
3233
late final Directory _packageDirectory;
3334

3435
const _gmsDependencyName = 'com.google.android.gms:play-services-cronet';
@@ -52,12 +53,14 @@ final implementationRegExp = RegExp(
5253
);
5354

5455
void main(List<String> args) async {
55-
if (Directory.current.path.endsWith('tool')) {
56-
_packageDirectory = Directory.current.parent;
57-
} else {
58-
_packageDirectory = Directory.current;
59-
}
60-
56+
final script = Platform.script.toFilePath();
57+
_scriptName = script.split(Platform.pathSeparator).last;
58+
_packageDirectory = Directory(
59+
Uri.directory(
60+
'${script.replaceAll(_scriptName, '')}'
61+
'..${Platform.pathSeparator}',
62+
).toFilePath(),
63+
);
6164
final latestVersion = await _getLatestCronetVersion();
6265
updateBuildGradle(latestVersion);
6366
updateExampleBuildGradle();
@@ -137,7 +140,9 @@ void updateReadme() {
137140
void updateImports() {
138141
print('Updating imports in Dart files');
139142
for (final file in _packageDirectory.listSync(recursive: true)) {
140-
if (file is File && file.path.endsWith('.dart')) {
143+
if (file is File &&
144+
file.path.endsWith('.dart') &&
145+
!file.path.contains(_scriptName)) {
141146
final updatedSource = file.readAsStringSync().replaceAll(
142147
'package:cronet_http/cronet_http.dart',
143148
'package:cronet_http_embedded/cronet_http_embedded.dart',

0 commit comments

Comments
 (0)