Skip to content
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

[cronet_http] ⬇️ Downgrade minSdkVersion to 21 #1104

Merged
merged 5 commits into from
Jan 11, 2024
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
5 changes: 3 additions & 2 deletions .github/workflows/cronet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ jobs:
# - .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' }}
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/
1 change: 1 addition & 0 deletions pkgs/cronet_http/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 1.0.1-wip

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

## 1.0.0

Expand Down
3 changes: 1 addition & 2 deletions pkgs/cronet_http/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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"
}
8 changes: 4 additions & 4 deletions pkgs/cronet_http/example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -70,7 +68,9 @@ flutter {
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
// 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"))
Copy link
Collaborator

Choose a reason for hiding this comment

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

I found a reference for this issue:
https://github.com/flutter/packages/blob/347929fc60f6c296714a8757730865bcfbfb32ce/packages/local_auth/local_auth_android/android/build.gradle#L71

Could you add a similar comment with a TODO (maybe linked to a new issue that you file) e.g.

    // TODO(<issue number):  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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you create a bug in the package:http issue tracking and put that in the TODO() so we don't lose track of it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure! Updated

// ""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"
Expand Down
19 changes: 12 additions & 7 deletions pkgs/cronet_http/tool/prepare_for_embedded.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -52,12 +53,14 @@ final implementationRegExp = RegExp(
);

void main(List<String> 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();
Expand Down Expand Up @@ -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',
Expand Down