From 77887a51500bdb371e3a60ace150acea3f367a7c Mon Sep 17 00:00:00 2001 From: Alex Li Date: Sat, 6 Jan 2024 00:57:05 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E2=AC=87=EF=B8=8F=20Downgrade=20`minSdkVer?= =?UTF-8?q?sion`=20to=2021?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/cronet.yml | 4 ---- pkgs/cronet_http/CHANGELOG.md | 4 ++++ pkgs/cronet_http/android/build.gradle | 2 +- .../example/android/app/build.gradle | 4 +--- pkgs/cronet_http/pubspec.yaml | 2 +- .../tool/prepare_for_embedded.dart | 19 ++++++++++++------- 6 files changed, 19 insertions(+), 16 deletions(-) diff --git a/.github/workflows/cronet.yml b/.github/workflows/cronet.yml index 0976a756ff..048c997509 100644 --- a/.github/workflows/cronet.yml +++ b/.github/workflows/cronet.yml @@ -58,10 +58,6 @@ jobs: uses: reactivecircus/android-emulator-runner@v2 if: always() && steps.install.outcome == 'success' with: - # api-level/minSdkVersion should be help in sync in: - # - .github/workflows/cronet.yml - # - pkgs/cronet_http/android/build.gradle - # - pkgs/cronet_http/example/android/app/build.gradle api-level: 28 target: ${{ matrix.package == 'cronet_http_embedded' && 'google_apis' || 'playstore' }} profile: pixel diff --git a/pkgs/cronet_http/CHANGELOG.md b/pkgs/cronet_http/CHANGELOG.md index cf1fcbc208..c305b04bf3 100644 --- a/pkgs/cronet_http/CHANGELOG.md +++ b/pkgs/cronet_http/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.0.1-wip + +* Support Android API 21+. + ## 1.0.0 * No functional changes. diff --git a/pkgs/cronet_http/android/build.gradle b/pkgs/cronet_http/android/build.gradle index 96bb197c73..00248975d2 100644 --- a/pkgs/cronet_http/android/build.gradle +++ b/pkgs/cronet_http/android/build.gradle @@ -50,7 +50,7 @@ android { // - .github/workflows/cronet.yml // - pkgs/cronet_http/android/build.gradle // - pkgs/cronet_http/example/android/app/build.gradle - minSdkVersion 28 + minSdkVersion 21 } defaultConfig { diff --git a/pkgs/cronet_http/example/android/app/build.gradle b/pkgs/cronet_http/example/android/app/build.gradle index 1f7cd94749..b8e0a66a46 100644 --- a/pkgs/cronet_http/example/android/app/build.gradle +++ b/pkgs/cronet_http/example/android/app/build.gradle @@ -44,13 +44,11 @@ android { defaultConfig { applicationId "io.flutter.cronet_http_example" - // You can update the following values to match your application needs. - // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration. // api-level/minSdkVersion should be help in sync in: // - .github/workflows/cronet.yml // - pkgs/cronet_http/android/build.gradle // - pkgs/cronet_http/example/android/app/build.gradle - minSdkVersion 28 + minSdkVersion 21 targetSdkVersion flutter.targetSdkVersion versionCode flutterVersionCode.toInteger() versionName flutterVersionName diff --git a/pkgs/cronet_http/pubspec.yaml b/pkgs/cronet_http/pubspec.yaml index 5f4229ebf8..c9e0e4d0a0 100644 --- a/pkgs/cronet_http/pubspec.yaml +++ b/pkgs/cronet_http/pubspec.yaml @@ -1,5 +1,5 @@ name: cronet_http -version: 1.0.0 +version: 1.0.1-wip description: >- An Android Flutter plugin that provides access to the Cronet HTTP client. repository: https://github.com/dart-lang/http/tree/master/pkgs/cronet_http diff --git a/pkgs/cronet_http/tool/prepare_for_embedded.dart b/pkgs/cronet_http/tool/prepare_for_embedded.dart index aef0865ae8..16a2c0baef 100644 --- a/pkgs/cronet_http/tool/prepare_for_embedded.dart +++ b/pkgs/cronet_http/tool/prepare_for_embedded.dart @@ -29,6 +29,7 @@ import 'package:http/http.dart' as http; import 'package:xml/xml.dart'; import 'package:yaml_edit/yaml_edit.dart'; +late final String _scriptName; late final Directory _packageDirectory; const _gmsDependencyName = 'com.google.android.gms:play-services-cronet'; @@ -52,12 +53,14 @@ final implementationRegExp = RegExp( ); void main(List args) async { - if (Directory.current.path.endsWith('tool')) { - _packageDirectory = Directory.current.parent; - } else { - _packageDirectory = Directory.current; - } - + final script = Platform.script.toFilePath(); + _scriptName = script.split(Platform.pathSeparator).last; + _packageDirectory = Directory( + Uri.directory( + '${script.replaceAll(_scriptName, '')}' + '..${Platform.pathSeparator}', + ).toFilePath(), + ); final latestVersion = await _getLatestCronetVersion(); updateBuildGradle(latestVersion); updateExampleBuildGradle(); @@ -137,7 +140,9 @@ void updateReadme() { void updateImports() { print('Updating imports in Dart files'); for (final file in _packageDirectory.listSync(recursive: true)) { - if (file is File && file.path.endsWith('.dart')) { + if (file is File && + file.path.endsWith('.dart') && + !file.path.contains(_scriptName)) { final updatedSource = file.readAsStringSync().replaceAll( 'package:cronet_http/cronet_http.dart', 'package:cronet_http_embedded/cronet_http_embedded.dart', From 6a7db8a8a3f31fed7ad29456dd7ea78f12123fe4 Mon Sep 17 00:00:00 2001 From: Alex Li Date: Wed, 10 Jan 2024 10:32:19 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=92=9A=20Fix=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/cronet.yml | 9 +++++++-- pkgs/cronet_http/android/build.gradle | 1 - pkgs/cronet_http/example/android/app/build.gradle | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cronet.yml b/.github/workflows/cronet.yml index 80d55ee660..74571fb904 100644 --- a/.github/workflows/cronet.yml +++ b/.github/workflows/cronet.yml @@ -58,7 +58,12 @@ jobs: uses: reactivecircus/android-emulator-runner@v2 if: always() && steps.install.outcome == 'success' with: - api-level: 28 - target: ${{ matrix.package == 'cronet_http_embedded' && 'google_apis' || 'playstore' }} + # api-level/minSdkVersion should be help in sync in: + # - .github/workflows/cronet.yml + # - pkgs/cronet_http/android/build.gradle + # - pkgs/cronet_http/example/android/app/build.gradle + api-level: 21 + arch: x86_64 + target: ${{ matrix.package == 'cronet_http_embedded' && 'default' || 'google_apis' }} profile: pixel script: cd 'pkgs/${{ matrix.package }}/example' && flutter test --timeout=1200s integration_test/ diff --git a/pkgs/cronet_http/android/build.gradle b/pkgs/cronet_http/android/build.gradle index 00248975d2..af945d9d8b 100644 --- a/pkgs/cronet_http/android/build.gradle +++ b/pkgs/cronet_http/android/build.gradle @@ -65,6 +65,5 @@ android { } dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation "com.google.android.gms:play-services-cronet:18.0.1" } diff --git a/pkgs/cronet_http/example/android/app/build.gradle b/pkgs/cronet_http/example/android/app/build.gradle index b8e0a66a46..34673724a5 100644 --- a/pkgs/cronet_http/example/android/app/build.gradle +++ b/pkgs/cronet_http/example/android/app/build.gradle @@ -68,7 +68,7 @@ flutter { } dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.8.0")) // ""com.google.android.gms:play-services-cronet" is only present so that // `jnigen` will work. Applications should not include this line. implementation "com.google.android.gms:play-services-cronet:18.0.1" From 38e9c9e7040b5490d3a3786e6b9426af5e21f2e6 Mon Sep 17 00:00:00 2001 From: Alex Li Date: Thu, 11 Jan 2024 07:15:03 +0800 Subject: [PATCH 3/4] Update build.gradle --- pkgs/cronet_http/example/android/app/build.gradle | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/cronet_http/example/android/app/build.gradle b/pkgs/cronet_http/example/android/app/build.gradle index 34673724a5..7b76221f64 100644 --- a/pkgs/cronet_http/example/android/app/build.gradle +++ b/pkgs/cronet_http/example/android/app/build.gradle @@ -68,6 +68,8 @@ flutter { } dependencies { + // TODO(flutter/125062): org.jetbrains.kotlin:kotlin-bom artifact purpose is to align kotlin stdlib and related code versions. + // This should be removed when https://github.com/flutter/flutter/issues/125062 is fixed. implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.8.0")) // ""com.google.android.gms:play-services-cronet" is only present so that // `jnigen` will work. Applications should not include this line. From 5044e7f44a3022e43152a9851eb5c4381ae2cad1 Mon Sep 17 00:00:00 2001 From: Alex Li Date: Thu, 11 Jan 2024 08:31:04 +0800 Subject: [PATCH 4/4] Update build.gradle --- pkgs/cronet_http/example/android/app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/cronet_http/example/android/app/build.gradle b/pkgs/cronet_http/example/android/app/build.gradle index 7b76221f64..dfd74270c3 100644 --- a/pkgs/cronet_http/example/android/app/build.gradle +++ b/pkgs/cronet_http/example/android/app/build.gradle @@ -68,7 +68,7 @@ flutter { } dependencies { - // TODO(flutter/125062): org.jetbrains.kotlin:kotlin-bom artifact purpose is to align kotlin stdlib and related code versions. + // TODO(#1112): org.jetbrains.kotlin:kotlin-bom artifact purpose is to align kotlin stdlib and related code versions. // This should be removed when https://github.com/flutter/flutter/issues/125062 is fixed. implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.8.0")) // ""com.google.android.gms:play-services-cronet" is only present so that