From 6870096246d79c79c776555404f1767e621a65e7 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Wed, 10 Sep 2025 07:07:01 -0400 Subject: [PATCH] [url_launcher] Temporarily restore Android 21 support The change to drop API 21-23 support was intended to set the minimum Flutter version to 3.35, but didn't actually do so. This reverts the changes to drop 21-23, so that anyone who got the broken version can update to a working version, and then I'll follow up with a new PR that re-lands the change but with the missed SDK constraint change. --- .../url_launcher/url_launcher_android/CHANGELOG.md | 5 +++++ .../url_launcher_android/android/build.gradle | 2 +- .../plugins/urllauncher/WebViewActivity.java | 14 ++++++++++++++ .../url_launcher/url_launcher_android/pubspec.yaml | 2 +- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/packages/url_launcher/url_launcher_android/CHANGELOG.md b/packages/url_launcher/url_launcher_android/CHANGELOG.md index fe1d4e6e22d..b8f685f30f8 100644 --- a/packages/url_launcher/url_launcher_android/CHANGELOG.md +++ b/packages/url_launcher/url_launcher_android/CHANGELOG.md @@ -1,3 +1,8 @@ +## 6.3.20 + +* Restore SDK 21-23 support, as the previous change was intended + to require Flutter 3.35, but didn't. + ## 6.3.19 * Updates minimum supported SDK version to Flutter 3.35. diff --git a/packages/url_launcher/url_launcher_android/android/build.gradle b/packages/url_launcher/url_launcher_android/android/build.gradle index 825ddeabad5..390519a37a8 100644 --- a/packages/url_launcher/url_launcher_android/android/build.gradle +++ b/packages/url_launcher/url_launcher_android/android/build.gradle @@ -29,7 +29,7 @@ android { compileSdk = flutter.compileSdkVersion defaultConfig { - minSdkVersion 24 + minSdkVersion 21 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/packages/url_launcher/url_launcher_android/android/src/main/java/io/flutter/plugins/urllauncher/WebViewActivity.java b/packages/url_launcher/url_launcher_android/android/src/main/java/io/flutter/plugins/urllauncher/WebViewActivity.java index 026e86a4fc1..3ae49cece79 100644 --- a/packages/url_launcher/url_launcher_android/android/src/main/java/io/flutter/plugins/urllauncher/WebViewActivity.java +++ b/packages/url_launcher/url_launcher_android/android/src/main/java/io/flutter/plugins/urllauncher/WebViewActivity.java @@ -9,6 +9,7 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; +import android.os.Build; import android.os.Bundle; import android.os.Message; import android.provider.Browser; @@ -19,6 +20,7 @@ import android.webkit.WebViewClient; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.annotation.RequiresApi; import androidx.annotation.VisibleForTesting; import androidx.core.content.ContextCompat; import java.util.Collections; @@ -47,6 +49,7 @@ public void onReceive(Context context, Intent intent) { private final WebViewClient webViewClient = new WebViewClient() { + @RequiresApi(Build.VERSION_CODES.N) @Override public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) { view.loadUrl(request.getUrl().toString()); @@ -72,6 +75,17 @@ public boolean shouldOverrideUrlLoading( webview.loadUrl(request.getUrl().toString()); return true; } + + /* + * This method is deprecated in API 24. Still overridden to support + * earlier Android versions. + */ + @SuppressWarnings("deprecation") + @Override + public boolean shouldOverrideUrlLoading(WebView view, String url) { + webview.loadUrl(url); + return true; + } }; final WebView newWebView = new WebView(webview.getContext()); diff --git a/packages/url_launcher/url_launcher_android/pubspec.yaml b/packages/url_launcher/url_launcher_android/pubspec.yaml index 117cf02c367..5e024ca8910 100644 --- a/packages/url_launcher/url_launcher_android/pubspec.yaml +++ b/packages/url_launcher/url_launcher_android/pubspec.yaml @@ -2,7 +2,7 @@ name: url_launcher_android description: Android implementation of the url_launcher plugin. repository: https://github.com/flutter/packages/tree/main/packages/url_launcher/url_launcher_android issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+url_launcher%22 -version: 6.3.19 +version: 6.3.20 environment: sdk: ^3.7.0