From 4506ff809d952e30f7c8d7343804f2d3ea3d510a Mon Sep 17 00:00:00 2001 From: Alex Li Date: Thu, 7 Dec 2023 13:51:16 +0800 Subject: [PATCH 01/21] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Reorg=20workflow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/cronet.yml | 49 ++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/.github/workflows/cronet.yml b/.github/workflows/cronet.yml index 7bc1a4f089..ee3ccac651 100644 --- a/.github/workflows/cronet.yml +++ b/.github/workflows/cronet.yml @@ -6,10 +6,12 @@ on: - main - master paths: + - '.github/workflows/**' - 'pkgs/cronet_http/**' - 'pkgs/http_client_conformance_tests/**' pull_request: paths: + - '.github/workflows/**' - 'pkgs/cronet_http/**' - 'pkgs/http_client_conformance_tests/**' schedule: @@ -19,48 +21,45 @@ env: PUB_ENVIRONMENT: bot.github jobs: - analyze: - name: Lint and static analysis - runs-on: ubuntu-latest - defaults: - run: - working-directory: pkgs/cronet_http + verify: + name: Format & Analyze & Test + runs-on: macos-latest + strategy: + matrix: + package: ['cronet_http', 'cronet_http_embedded'] steps: - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + distribution: 'zulu' + java-version: '17' - uses: subosito/flutter-action@v2 with: - # TODO: Change to 'stable' when a release version of flutter - # pins version 1.21.1 or later of 'package:test' - channel: 'master' + channel: 'stable' + - name: Make cronet_http_embedded copy + if: ${{ matrix.package == 'cronet_http_embedded' }} + run: | + cp -r pkgs/cronet_http pkgs/cronet_http_embedded + cd pkgs/cronet_http_embedded + flutter pub get && dart tool/prepare_for_embedded.dart - id: install name: Install dependencies + working-directory: 'pkgs/${{ matrix.package }}' run: flutter pub get - name: Check formatting + working-directory: 'pkgs/${{ matrix.package }}' run: dart format --output=none --set-exit-if-changed . if: always() && steps.install.outcome == 'success' - name: Analyze code + working-directory: 'pkgs/${{ matrix.package }}' run: flutter analyze --fatal-infos if: always() && steps.install.outcome == 'success' - - test: - # Test package:cupertino_http use flutter integration tests. - needs: analyze - name: "Build and test" - runs-on: macos-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-java@v4 - with: - distribution: 'zulu' - java-version: '17' - - uses: subosito/flutter-action@v2 - with: - channel: 'stable' - name: Run tests uses: reactivecircus/android-emulator-runner@v2 + if: always() && steps.install.outcome == 'success' with: api-level: 28 target: playstore arch: x86_64 profile: pixel - script: cd ./pkgs/cronet_http/example && flutter test --timeout=1200s integration_test/ + script: cd 'pkgs/${{ matrix.package }}/example' && flutter test --timeout=1200s integration_test/ From 91e5ba6c54f44ce51e059e17617cff92c9bd5802 Mon Sep 17 00:00:00 2001 From: Alex Li Date: Thu, 7 Dec 2023 13:51:30 +0800 Subject: [PATCH 02/21] =?UTF-8?q?=F0=9F=91=B7=20Tool=20support?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkgs/cronet_http/tool/prepare_for_embedded.dart | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/pkgs/cronet_http/tool/prepare_for_embedded.dart b/pkgs/cronet_http/tool/prepare_for_embedded.dart index e0f99d7a23..3a1a567d04 100644 --- a/pkgs/cronet_http/tool/prepare_for_embedded.dart +++ b/pkgs/cronet_http/tool/prepare_for_embedded.dart @@ -40,7 +40,9 @@ final _cronetVersionUri = Uri.https( 'android/maven2/org/chromium/net/group-index.xml', ); -void main() async { +/// Runs `prepare_for_embedded.dart true` for publishing, +/// or only the Android dependency will be modified. +void main(List args) async { if (Directory.current.path.endsWith('tool')) { _packageDirectory = Directory.current.parent; } else { @@ -49,8 +51,10 @@ void main() async { final latestVersion = await _getLatestCronetVersion(); updateCronetDependency(latestVersion); - updatePubSpec(); - updateReadme(); + if (args.isNotEmpty && args.first == 'true') { + updatePubSpec(); + updateReadme(); + } } Future _getLatestCronetVersion() async { @@ -88,13 +92,18 @@ void updateCronetDependency(String latestVersion) { fBuildGradle.writeAsStringSync(newGradleContent); } -/// Update pubspec.yaml +/// Update pubspec.yaml and example/pubspec.yaml void updatePubSpec() { final fPubspec = File('${_packageDirectory.path}/pubspec.yaml'); final yamlEditor = YamlEditor(fPubspec.readAsStringSync()) ..update(['name'], _packageName) ..update(['description'], _packageDescription); fPubspec.writeAsStringSync(yamlEditor.toString()); + final examplePubspec = File('${_packageDirectory.path}/pubspec.yaml'); + final replaced = examplePubspec + .readAsStringSync() + .replaceAll('cronet_http:', 'cronet_http_embedded:'); + examplePubspec.writeAsStringSync(replaced); } /// Move README_EMBEDDED.md to replace README.md From aee5e9af4bf78fcd75692e6ad465630718ba4351 Mon Sep 17 00:00:00 2001 From: Alex Li Date: Thu, 7 Dec 2023 14:19:52 +0800 Subject: [PATCH 03/21] =?UTF-8?q?=F0=9F=94=8A=20++?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkgs/cronet_http/tool/prepare_for_embedded.dart | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/pkgs/cronet_http/tool/prepare_for_embedded.dart b/pkgs/cronet_http/tool/prepare_for_embedded.dart index 3a1a567d04..e73543c33f 100644 --- a/pkgs/cronet_http/tool/prepare_for_embedded.dart +++ b/pkgs/cronet_http/tool/prepare_for_embedded.dart @@ -40,7 +40,7 @@ final _cronetVersionUri = Uri.https( 'android/maven2/org/chromium/net/group-index.xml', ); -/// Runs `prepare_for_embedded.dart true` for publishing, +/// Runs `prepare_for_embedded.dart publish` for publishing, /// or only the Android dependency will be modified. void main(List args) async { if (Directory.current.path.endsWith('tool')) { @@ -51,7 +51,7 @@ void main(List args) async { final latestVersion = await _getLatestCronetVersion(); updateCronetDependency(latestVersion); - if (args.isNotEmpty && args.first == 'true') { + if (args.isNotEmpty && args.first == 'publish') { updatePubSpec(); updateReadme(); } @@ -73,7 +73,7 @@ Future _getLatestCronetVersion() async { return versions.last; } -/// Update android/build.gradle +/// Update android/build.gradle. void updateCronetDependency(String latestVersion) { final fBuildGradle = File('${_packageDirectory.path}/android/build.gradle'); final gradleContent = fBuildGradle.readAsStringSync(); @@ -92,22 +92,25 @@ void updateCronetDependency(String latestVersion) { fBuildGradle.writeAsStringSync(newGradleContent); } -/// Update pubspec.yaml and example/pubspec.yaml +/// Update pubspec.yaml and example/pubspec.yaml. void updatePubSpec() { + print('Updating pubspec.yaml'); final fPubspec = File('${_packageDirectory.path}/pubspec.yaml'); final yamlEditor = YamlEditor(fPubspec.readAsStringSync()) ..update(['name'], _packageName) ..update(['description'], _packageDescription); fPubspec.writeAsStringSync(yamlEditor.toString()); - final examplePubspec = File('${_packageDirectory.path}/pubspec.yaml'); + print('Updating example/pubspec.yaml'); + final examplePubspec = File('${_packageDirectory.path}/example/pubspec.yaml'); final replaced = examplePubspec .readAsStringSync() .replaceAll('cronet_http:', 'cronet_http_embedded:'); examplePubspec.writeAsStringSync(replaced); } -/// Move README_EMBEDDED.md to replace README.md +/// Move README_EMBEDDED.md to replace README.md. void updateReadme() { + print('Updating README.md from README_EMBEDDED.md'); File('${_packageDirectory.path}/README.md').deleteSync(); File('${_packageDirectory.path}/README_EMBEDDED.md') .renameSync('${_packageDirectory.path}/README.md'); From f86858019f1f72882fa66a7aac4b6d51516b7109 Mon Sep 17 00:00:00 2001 From: Alex Li Date: Thu, 7 Dec 2023 14:20:21 +0800 Subject: [PATCH 04/21] =?UTF-8?q?=F0=9F=9A=9A=20--?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/android/app/src/debug/AndroidManifest.xml | 2 +- .../example/android/app/src/main/AndroidManifest.xml | 2 +- .../example => io/flutter}/cronet_http_example/MainActivity.kt | 2 +- .../example/android/app/src/profile/AndroidManifest.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) rename pkgs/cronet_http/example/android/app/src/main/kotlin/{com/example => io/flutter}/cronet_http_example/MainActivity.kt (70%) diff --git a/pkgs/cronet_http/example/android/app/src/debug/AndroidManifest.xml b/pkgs/cronet_http/example/android/app/src/debug/AndroidManifest.xml index b17be9f3cb..6170951031 100644 --- a/pkgs/cronet_http/example/android/app/src/debug/AndroidManifest.xml +++ b/pkgs/cronet_http/example/android/app/src/debug/AndroidManifest.xml @@ -1,4 +1,4 @@ + package="io.flutter.cronet_http_example"> diff --git a/pkgs/cronet_http/example/android/app/src/main/AndroidManifest.xml b/pkgs/cronet_http/example/android/app/src/main/AndroidManifest.xml index e8d5f3f208..254760d3ed 100644 --- a/pkgs/cronet_http/example/android/app/src/main/AndroidManifest.xml +++ b/pkgs/cronet_http/example/android/app/src/main/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="io.flutter.cronet_http_example"> + package="io.flutter.cronet_http_example"> From e51d81605d1c30e5d54245b5323322d361b2f903 Mon Sep 17 00:00:00 2001 From: Alex Li Date: Thu, 7 Dec 2023 14:39:13 +0800 Subject: [PATCH 05/21] =?UTF-8?q?=F0=9F=90=9B=20Fix=20the=20example?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkgs/cronet_http/android/build.gradle | 12 ++++----- .../example/android/app/build.gradle | 10 +------- .../app/FlutterMultiDexApplication.java | 25 +++++++++++++++++++ .../plugins/GeneratedPluginRegistrant.java | 22 +++++++++++----- pkgs/cronet_http/example/android/build.gradle | 6 ++--- .../gradle/wrapper/gradle-wrapper.properties | 2 +- 6 files changed, 52 insertions(+), 25 deletions(-) create mode 100644 pkgs/cronet_http/example/android/app/src/main/java/io/flutter/app/FlutterMultiDexApplication.java diff --git a/pkgs/cronet_http/android/build.gradle b/pkgs/cronet_http/android/build.gradle index 3a91d8a295..6a91b6ad70 100644 --- a/pkgs/cronet_http/android/build.gradle +++ b/pkgs/cronet_http/android/build.gradle @@ -2,14 +2,14 @@ group 'io.flutter.plugins.cronet_http' version '1.0-SNAPSHOT' buildscript { - ext.kotlin_version = '1.6.10' + ext.kotlin_version = '1.7.21' repositories { google() mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:7.1.2' + classpath 'com.android.tools.build:gradle:7.3.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } @@ -26,16 +26,16 @@ apply plugin: 'kotlin-android' android { compileSdkVersion 31 + // Conditional for compatibility with AGP <4.2. + if (project.android.hasProperty("namespace")) { + namespace 'io.flutter.plugins.cronet_http' + } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } - kotlinOptions { - jvmTarget = '1.8' - } - sourceSets { main.java.srcDirs += 'src/main/kotlin' } diff --git a/pkgs/cronet_http/example/android/app/build.gradle b/pkgs/cronet_http/example/android/app/build.gradle index 88b33564c3..5da15f658e 100644 --- a/pkgs/cronet_http/example/android/app/build.gradle +++ b/pkgs/cronet_http/example/android/app/build.gradle @@ -29,15 +29,6 @@ android { compileSdkVersion flutter.compileSdkVersion ndkVersion flutter.ndkVersion - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - - kotlinOptions { - jvmTarget = '1.8' - } - sourceSets { main.java.srcDirs += 'src/main/kotlin' } @@ -50,6 +41,7 @@ android { targetSdkVersion flutter.targetSdkVersion versionCode flutterVersionCode.toInteger() versionName flutterVersionName + multiDexEnabled true } buildTypes { diff --git a/pkgs/cronet_http/example/android/app/src/main/java/io/flutter/app/FlutterMultiDexApplication.java b/pkgs/cronet_http/example/android/app/src/main/java/io/flutter/app/FlutterMultiDexApplication.java new file mode 100644 index 0000000000..752fc185d4 --- /dev/null +++ b/pkgs/cronet_http/example/android/app/src/main/java/io/flutter/app/FlutterMultiDexApplication.java @@ -0,0 +1,25 @@ +// Generated file. +// +// If you wish to remove Flutter's multidex support, delete this entire file. +// +// Modifications to this file should be done in a copy under a different name +// as this file may be regenerated. + +package io.flutter.app; + +import android.app.Application; +import android.content.Context; +import androidx.annotation.CallSuper; +import androidx.multidex.MultiDex; + +/** + * Extension of {@link android.app.Application}, adding multidex support. + */ +public class FlutterMultiDexApplication extends Application { + @Override + @CallSuper + protected void attachBaseContext(Context base) { + super.attachBaseContext(base); + MultiDex.install(this); + } +} diff --git a/pkgs/cronet_http/example/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java b/pkgs/cronet_http/example/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java index 90015fdc18..3772f022a0 100644 --- a/pkgs/cronet_http/example/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java +++ b/pkgs/cronet_http/example/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java @@ -15,15 +15,25 @@ public final class GeneratedPluginRegistrant { private static final String TAG = "GeneratedPluginRegistrant"; public static void registerWith(@NonNull FlutterEngine flutterEngine) { - try { - flutterEngine.getPlugins().add(new io.flutter.plugins.cronet_http.CronetHttpPlugin()); - } catch(Exception e) { - Log.e(TAG, "Error registering plugin cronet_http, io.flutter.plugins.cronet_http.CronetHttpPlugin", e); - } try { flutterEngine.getPlugins().add(new dev.flutter.plugins.integration_test.IntegrationTestPlugin()); - } catch(Exception e) { + } catch (Exception e) { Log.e(TAG, "Error registering plugin integration_test, dev.flutter.plugins.integration_test.IntegrationTestPlugin", e); } + try { + flutterEngine.getPlugins().add(new com.github.dart_lang.jni.JniPlugin()); + } catch (Exception e) { + Log.e(TAG, "Error registering plugin jni, com.github.dart_lang.jni.JniPlugin", e); + } + try { + flutterEngine.getPlugins().add(new io.flutter.plugins.pathprovider.PathProviderPlugin()); + } catch (Exception e) { + Log.e(TAG, "Error registering plugin path_provider_android, io.flutter.plugins.pathprovider.PathProviderPlugin", e); + } + try { + flutterEngine.getPlugins().add(new com.tekartik.sqflite.SqflitePlugin()); + } catch (Exception e) { + Log.e(TAG, "Error registering plugin sqflite, com.tekartik.sqflite.SqflitePlugin", e); + } } } diff --git a/pkgs/cronet_http/example/android/build.gradle b/pkgs/cronet_http/example/android/build.gradle index 83ae220041..ce647a433b 100644 --- a/pkgs/cronet_http/example/android/build.gradle +++ b/pkgs/cronet_http/example/android/build.gradle @@ -1,12 +1,12 @@ buildscript { - ext.kotlin_version = '1.6.10' + ext.kotlin_version = '1.7.10' repositories { google() mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:7.1.2' + classpath 'com.android.tools.build:gradle:7.4.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } @@ -26,6 +26,6 @@ subprojects { project.evaluationDependsOn(':app') } -task clean(type: Delete) { +tasks.register("clean", Delete) { delete rootProject.buildDir } diff --git a/pkgs/cronet_http/example/android/gradle/wrapper/gradle-wrapper.properties b/pkgs/cronet_http/example/android/gradle/wrapper/gradle-wrapper.properties index cc5527d781..cfe88f6904 100644 --- a/pkgs/cronet_http/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/pkgs/cronet_http/example/android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip From c7bcdbf4612fe552749e6f6fa5441957a424cf83 Mon Sep 17 00:00:00 2001 From: Alex Li Date: Wed, 20 Dec 2023 09:46:21 +0800 Subject: [PATCH 06/21] Update cronet.yml --- .github/workflows/cronet.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cronet.yml b/.github/workflows/cronet.yml index ee3ccac651..e860547a13 100644 --- a/.github/workflows/cronet.yml +++ b/.github/workflows/cronet.yml @@ -23,7 +23,7 @@ env: jobs: verify: name: Format & Analyze & Test - runs-on: macos-latest + runs-on: ubuntu-latest strategy: matrix: package: ['cronet_http', 'cronet_http_embedded'] @@ -59,7 +59,7 @@ jobs: if: always() && steps.install.outcome == 'success' with: api-level: 28 - target: playstore + target: ${{ matrix.package == 'cronet_http_embedded' && 'default' || 'playstore' }} arch: x86_64 profile: pixel script: cd 'pkgs/${{ matrix.package }}/example' && flutter test --timeout=1200s integration_test/ From 58cd8db22cacf1fd16ba001b9203610ae0373546 Mon Sep 17 00:00:00 2001 From: Alex Li Date: Wed, 20 Dec 2023 09:59:45 +0800 Subject: [PATCH 07/21] Update cronet.yml --- .github/workflows/cronet.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cronet.yml b/.github/workflows/cronet.yml index e860547a13..383942c53d 100644 --- a/.github/workflows/cronet.yml +++ b/.github/workflows/cronet.yml @@ -59,7 +59,7 @@ jobs: if: always() && steps.install.outcome == 'success' with: api-level: 28 - target: ${{ matrix.package == 'cronet_http_embedded' && 'default' || 'playstore' }} + target: playstore arch: x86_64 profile: pixel script: cd 'pkgs/${{ matrix.package }}/example' && flutter test --timeout=1200s integration_test/ From 8fe848dcbcd7b93fdacd3d657345fc2ffc1918ba Mon Sep 17 00:00:00 2001 From: Alex Li Date: Wed, 20 Dec 2023 10:28:38 +0800 Subject: [PATCH 08/21] Update cronet.yml --- .github/workflows/cronet.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cronet.yml b/.github/workflows/cronet.yml index 383942c53d..37e38d5415 100644 --- a/.github/workflows/cronet.yml +++ b/.github/workflows/cronet.yml @@ -23,7 +23,7 @@ env: jobs: verify: name: Format & Analyze & Test - runs-on: ubuntu-latest + runs-on: macos-latest strategy: matrix: package: ['cronet_http', 'cronet_http_embedded'] @@ -59,7 +59,7 @@ jobs: if: always() && steps.install.outcome == 'success' with: api-level: 28 - target: playstore + target: ${{ matrix.package == 'cronet_http_embedded' && 'default' || 'playstore' }} arch: x86_64 profile: pixel script: cd 'pkgs/${{ matrix.package }}/example' && flutter test --timeout=1200s integration_test/ From 0637349cfd4546670e0db4b699b8ddbfa804c6a8 Mon Sep 17 00:00:00 2001 From: Alex Li Date: Wed, 20 Dec 2023 10:46:02 +0800 Subject: [PATCH 09/21] Update build.gradle --- pkgs/cronet_http/example/android/app/build.gradle | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pkgs/cronet_http/example/android/app/build.gradle b/pkgs/cronet_http/example/android/app/build.gradle index 5da15f658e..02e4b7551e 100644 --- a/pkgs/cronet_http/example/android/app/build.gradle +++ b/pkgs/cronet_http/example/android/app/build.gradle @@ -29,6 +29,15 @@ android { compileSdkVersion flutter.compileSdkVersion ndkVersion flutter.ndkVersion + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = '1.8' + } + sourceSets { main.java.srcDirs += 'src/main/kotlin' } @@ -37,11 +46,10 @@ android { 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. - minSdkVersion flutter.minSdkVersion + minSdkVersion 21 targetSdkVersion flutter.targetSdkVersion versionCode flutterVersionCode.toInteger() versionName flutterVersionName - multiDexEnabled true } buildTypes { From c6ea3b4da79747481d8ac947fe859b65f8644262 Mon Sep 17 00:00:00 2001 From: Alex Li Date: Wed, 20 Dec 2023 10:51:19 +0800 Subject: [PATCH 10/21] Update build.gradle --- pkgs/cronet_http/android/build.gradle | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pkgs/cronet_http/android/build.gradle b/pkgs/cronet_http/android/build.gradle index 6a91b6ad70..506803354b 100644 --- a/pkgs/cronet_http/android/build.gradle +++ b/pkgs/cronet_http/android/build.gradle @@ -9,7 +9,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:7.3.0' + classpath 'com.android.tools.build:gradle:7.4.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } @@ -25,23 +25,28 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' android { - compileSdkVersion 31 // Conditional for compatibility with AGP <4.2. if (project.android.hasProperty("namespace")) { namespace 'io.flutter.plugins.cronet_http' } + compileSdkVersion 34 + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } + kotlinOptions { + jvmTarget = '1.8' + } + sourceSets { main.java.srcDirs += 'src/main/kotlin' } defaultConfig { - minSdkVersion 16 + minSdkVersion 19 } defaultConfig { From 368be83e7b075722c25ac08cc26ed7e14b19c69d Mon Sep 17 00:00:00 2001 From: Alex Li Date: Wed, 20 Dec 2023 10:51:46 +0800 Subject: [PATCH 11/21] Update build.gradle --- pkgs/cronet_http/android/build.gradle | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/cronet_http/android/build.gradle b/pkgs/cronet_http/android/build.gradle index 506803354b..f31ff874a6 100644 --- a/pkgs/cronet_http/android/build.gradle +++ b/pkgs/cronet_http/android/build.gradle @@ -37,9 +37,9 @@ android { targetCompatibility JavaVersion.VERSION_1_8 } - kotlinOptions { - jvmTarget = '1.8' - } + kotlinOptions { + jvmTarget = '1.8' + } sourceSets { main.java.srcDirs += 'src/main/kotlin' From f55683d441bdb9dfa3138d8123e9e1c589bec263 Mon Sep 17 00:00:00 2001 From: Alex Li Date: Wed, 20 Dec 2023 10:52:28 +0800 Subject: [PATCH 12/21] Delete pkgs/cronet_http/example/android/app/src/main/java/io/flutter/app/FlutterMultiDexApplication.java --- .../app/FlutterMultiDexApplication.java | 25 ------------------- 1 file changed, 25 deletions(-) delete mode 100644 pkgs/cronet_http/example/android/app/src/main/java/io/flutter/app/FlutterMultiDexApplication.java diff --git a/pkgs/cronet_http/example/android/app/src/main/java/io/flutter/app/FlutterMultiDexApplication.java b/pkgs/cronet_http/example/android/app/src/main/java/io/flutter/app/FlutterMultiDexApplication.java deleted file mode 100644 index 752fc185d4..0000000000 --- a/pkgs/cronet_http/example/android/app/src/main/java/io/flutter/app/FlutterMultiDexApplication.java +++ /dev/null @@ -1,25 +0,0 @@ -// Generated file. -// -// If you wish to remove Flutter's multidex support, delete this entire file. -// -// Modifications to this file should be done in a copy under a different name -// as this file may be regenerated. - -package io.flutter.app; - -import android.app.Application; -import android.content.Context; -import androidx.annotation.CallSuper; -import androidx.multidex.MultiDex; - -/** - * Extension of {@link android.app.Application}, adding multidex support. - */ -public class FlutterMultiDexApplication extends Application { - @Override - @CallSuper - protected void attachBaseContext(Context base) { - super.attachBaseContext(base); - MultiDex.install(this); - } -} From e3a9c148ff113221b83b43c11b3f3d8c91e30e22 Mon Sep 17 00:00:00 2001 From: Alex Li Date: Wed, 20 Dec 2023 10:52:49 +0800 Subject: [PATCH 13/21] Update build.gradle --- pkgs/cronet_http/example/android/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/cronet_http/example/android/build.gradle b/pkgs/cronet_http/example/android/build.gradle index ce647a433b..954fa1cd5c 100644 --- a/pkgs/cronet_http/example/android/build.gradle +++ b/pkgs/cronet_http/example/android/build.gradle @@ -1,5 +1,5 @@ buildscript { - ext.kotlin_version = '1.7.10' + ext.kotlin_version = '1.7.21' repositories { google() mavenCentral() From 2c25829036332461e6c0f020449cba31478c2178 Mon Sep 17 00:00:00 2001 From: Alex Li Date: Wed, 20 Dec 2023 11:07:18 +0800 Subject: [PATCH 14/21] Update build.gradle --- pkgs/cronet_http/android/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/cronet_http/android/build.gradle b/pkgs/cronet_http/android/build.gradle index f31ff874a6..164d96e104 100644 --- a/pkgs/cronet_http/android/build.gradle +++ b/pkgs/cronet_http/android/build.gradle @@ -30,7 +30,7 @@ android { namespace 'io.flutter.plugins.cronet_http' } - compileSdkVersion 34 + compileSdkVersion 31 compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 From 261fd37dc7e3dc9c170cc44830b55a1d8acdd641 Mon Sep 17 00:00:00 2001 From: Alex Li Date: Wed, 20 Dec 2023 11:42:26 +0800 Subject: [PATCH 15/21] Update cronet.yml --- .github/workflows/cronet.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cronet.yml b/.github/workflows/cronet.yml index 37e38d5415..e860547a13 100644 --- a/.github/workflows/cronet.yml +++ b/.github/workflows/cronet.yml @@ -23,7 +23,7 @@ env: jobs: verify: name: Format & Analyze & Test - runs-on: macos-latest + runs-on: ubuntu-latest strategy: matrix: package: ['cronet_http', 'cronet_http_embedded'] From 1d379e6960d13f6641ccd9d606d8be30f72dd824 Mon Sep 17 00:00:00 2001 From: Alex Li Date: Wed, 20 Dec 2023 12:04:00 +0800 Subject: [PATCH 16/21] Update cronet.yml --- .github/workflows/cronet.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cronet.yml b/.github/workflows/cronet.yml index e860547a13..00477b3bf7 100644 --- a/.github/workflows/cronet.yml +++ b/.github/workflows/cronet.yml @@ -62,4 +62,4 @@ jobs: target: ${{ matrix.package == 'cronet_http_embedded' && 'default' || 'playstore' }} arch: x86_64 profile: pixel - script: cd 'pkgs/${{ matrix.package }}/example' && flutter test --timeout=1200s integration_test/ + script: cd 'pkgs/${{ matrix.package }}/example' && flutter test --timeout=1500s integration_test/ From 05d63a801d69d902f96ed626f50d3b0499f9ca1b Mon Sep 17 00:00:00 2001 From: Alex Li Date: Wed, 20 Dec 2023 12:26:46 +0800 Subject: [PATCH 17/21] Update cronet.yml --- .github/workflows/cronet.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cronet.yml b/.github/workflows/cronet.yml index 00477b3bf7..ebcea17bcc 100644 --- a/.github/workflows/cronet.yml +++ b/.github/workflows/cronet.yml @@ -23,7 +23,7 @@ env: jobs: verify: name: Format & Analyze & Test - runs-on: ubuntu-latest + runs-on: macos-latest strategy: matrix: package: ['cronet_http', 'cronet_http_embedded'] From 702ad031ee052ee67b810fc1357cfca0b62ab46a Mon Sep 17 00:00:00 2001 From: Alex Li Date: Thu, 21 Dec 2023 15:26:49 +0800 Subject: [PATCH 18/21] =?UTF-8?q?=F0=9F=94=A8=20Update=20tool?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/cronet.yml | 2 +- .../tool/prepare_for_embedded.dart | 31 ++++++++++++++++--- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/.github/workflows/cronet.yml b/.github/workflows/cronet.yml index ebcea17bcc..37e38d5415 100644 --- a/.github/workflows/cronet.yml +++ b/.github/workflows/cronet.yml @@ -62,4 +62,4 @@ jobs: target: ${{ matrix.package == 'cronet_http_embedded' && 'default' || 'playstore' }} arch: x86_64 profile: pixel - script: cd 'pkgs/${{ matrix.package }}/example' && flutter test --timeout=1500s integration_test/ + script: cd 'pkgs/${{ matrix.package }}/example' && flutter test --timeout=1200s integration_test/ diff --git a/pkgs/cronet_http/tool/prepare_for_embedded.dart b/pkgs/cronet_http/tool/prepare_for_embedded.dart index e73543c33f..f98eb8f0af 100644 --- a/pkgs/cronet_http/tool/prepare_for_embedded.dart +++ b/pkgs/cronet_http/tool/prepare_for_embedded.dart @@ -51,10 +51,10 @@ void main(List args) async { final latestVersion = await _getLatestCronetVersion(); updateCronetDependency(latestVersion); - if (args.isNotEmpty && args.first == 'publish') { - updatePubSpec(); - updateReadme(); - } + updatePubSpec(); + updateReadme(); + updateImports(); + updateEntryPoint(); } Future _getLatestCronetVersion() async { @@ -115,3 +115,26 @@ void updateReadme() { File('${_packageDirectory.path}/README_EMBEDDED.md') .renameSync('${_packageDirectory.path}/README.md'); } + +void updateImports() { + for (final f in _packageDirectory.listSync( + recursive: true, + followLinks: false, + )) { + if (f case final file when file is File && file.path.endsWith('.dart')) { + final updatedSource = file.readAsStringSync().replaceAll( + 'package:cronet_http_embedded/cronet_http_embedded.dart', + 'package:cronet_http_embedded/cronet_http_embedded.dart', + ); + file.writeAsStringSync(updatedSource); + } + } +} + +void updateEntryPoint() { + File( + '${_packageDirectory.path}/lib/cronet_http.dart', + ).renameSync( + '${_packageDirectory.path}/lib/cronet_http_embedded.dart', + ); +} From 2efc1357c20ebd18cc47d56153da29f237e65618 Mon Sep 17 00:00:00 2001 From: Alex Li Date: Thu, 21 Dec 2023 16:01:30 +0800 Subject: [PATCH 19/21] Fix tool --- pkgs/cronet_http/tool/prepare_for_embedded.dart | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/pkgs/cronet_http/tool/prepare_for_embedded.dart b/pkgs/cronet_http/tool/prepare_for_embedded.dart index f98eb8f0af..2093c670b1 100644 --- a/pkgs/cronet_http/tool/prepare_for_embedded.dart +++ b/pkgs/cronet_http/tool/prepare_for_embedded.dart @@ -117,13 +117,11 @@ void updateReadme() { } void updateImports() { - for (final f in _packageDirectory.listSync( - recursive: true, - followLinks: false, - )) { - if (f case final file when file is File && file.path.endsWith('.dart')) { + print('Updating imports in Dart files'); + for (final file in _packageDirectory.listSync(recursive: true)) { + if (file is File && file.path.endsWith('.dart')) { final updatedSource = file.readAsStringSync().replaceAll( - 'package:cronet_http_embedded/cronet_http_embedded.dart', + 'package:cronet_http/cronet_http.dart', 'package:cronet_http_embedded/cronet_http_embedded.dart', ); file.writeAsStringSync(updatedSource); @@ -132,6 +130,7 @@ void updateImports() { } void updateEntryPoint() { + print('Renaming cronet_http.dart to cronet_http_embedded.dart'); File( '${_packageDirectory.path}/lib/cronet_http.dart', ).renameSync( From 6e3d84b48d2779c1c74df2e6bf8ed1a74b4d1472 Mon Sep 17 00:00:00 2001 From: Alex Li Date: Thu, 21 Dec 2023 16:24:04 +0800 Subject: [PATCH 20/21] Update cronet.yml --- .github/workflows/cronet.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cronet.yml b/.github/workflows/cronet.yml index 37e38d5415..e860547a13 100644 --- a/.github/workflows/cronet.yml +++ b/.github/workflows/cronet.yml @@ -23,7 +23,7 @@ env: jobs: verify: name: Format & Analyze & Test - runs-on: macos-latest + runs-on: ubuntu-latest strategy: matrix: package: ['cronet_http', 'cronet_http_embedded'] From 48dfa0ee002a422568751f87632ee79f105e1658 Mon Sep 17 00:00:00 2001 From: Alex Li Date: Thu, 21 Dec 2023 16:37:49 +0800 Subject: [PATCH 21/21] Update cronet.yml --- .github/workflows/cronet.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cronet.yml b/.github/workflows/cronet.yml index e860547a13..37e38d5415 100644 --- a/.github/workflows/cronet.yml +++ b/.github/workflows/cronet.yml @@ -23,7 +23,7 @@ env: jobs: verify: name: Format & Analyze & Test - runs-on: ubuntu-latest + runs-on: macos-latest strategy: matrix: package: ['cronet_http', 'cronet_http_embedded']