[various] Conditionalize the namespace in all Android plugins (#3836)
The recent change to add `namespace` to all plugins broke builds for apps using AGP 4.1 or earlier. This conditionalizes setting the namespace based on whether the property exists at all, making it compatible with both AGP 8.0 and AGP <4.2.
Updates tooling to enforce this for plugin (but not example app) build.gradle files.
Fixes https://github.com/flutter/flutter/issues/125621
diff --git a/packages/camera/camera_android/CHANGELOG.md b/packages/camera/camera_android/CHANGELOG.md
index 661cafd..91bd0fb 100644
--- a/packages/camera/camera_android/CHANGELOG.md
+++ b/packages/camera/camera_android/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.10.6+2
+
+* Fixes compatibility with AGP versions older than 4.2.
+
## 0.10.6+1
* Adds a namespace for compatibility with AGP 8.0.
diff --git a/packages/camera/camera_android/android/build.gradle b/packages/camera/camera_android/android/build.gradle
index 6b43770..53ac705 100644
--- a/packages/camera/camera_android/android/build.gradle
+++ b/packages/camera/camera_android/android/build.gradle
@@ -27,7 +27,10 @@
apply plugin: 'com.android.library'
android {
- namespace 'io.flutter.plugins.camera'
+ // Conditional for compatibility with AGP <4.2.
+ if (project.android.hasProperty("namespace")) {
+ namespace 'io.flutter.plugins.camera'
+ }
compileSdkVersion 33
defaultConfig {
diff --git a/packages/camera/camera_android/pubspec.yaml b/packages/camera/camera_android/pubspec.yaml
index 2b7c0c2..9c4fc57 100644
--- a/packages/camera/camera_android/pubspec.yaml
+++ b/packages/camera/camera_android/pubspec.yaml
@@ -2,7 +2,7 @@
description: Android implementation of the camera plugin.
repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_android
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
-version: 0.10.6+1
+version: 0.10.6+2
environment:
sdk: ">=2.17.0 <4.0.0"
diff --git a/packages/camera/camera_android_camerax/android/build.gradle b/packages/camera/camera_android_camerax/android/build.gradle
index 1ae38c2..d056449 100644
--- a/packages/camera/camera_android_camerax/android/build.gradle
+++ b/packages/camera/camera_android_camerax/android/build.gradle
@@ -22,7 +22,10 @@
apply plugin: 'com.android.library'
android {
- namespace 'io.flutter.plugins.camerax'
+ // Conditional for compatibility with AGP <4.2.
+ if (project.android.hasProperty("namespace")) {
+ namespace 'io.flutter.plugins.camerax'
+ }
// CameraX dependencies require compilation against version 33 or later.
compileSdkVersion 33
diff --git a/packages/espresso/CHANGELOG.md b/packages/espresso/CHANGELOG.md
index 7204107..af45fb8 100644
--- a/packages/espresso/CHANGELOG.md
+++ b/packages/espresso/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.3.0+4
+
+* Fixes compatibility with AGP versions older than 4.2.
+
## 0.3.0+3
* Adds `targetCompatibilty` matching `sourceCompatibility` for older toolchains.
diff --git a/packages/espresso/android/build.gradle b/packages/espresso/android/build.gradle
index 034779a..1d28a98 100644
--- a/packages/espresso/android/build.gradle
+++ b/packages/espresso/android/build.gradle
@@ -22,7 +22,10 @@
apply plugin: 'com.android.library'
android {
- namespace 'com.example.espresso'
+ // Conditional for compatibility with AGP <4.2.
+ if (project.android.hasProperty("namespace")) {
+ namespace 'com.example.espresso'
+ }
compileSdkVersion 33
defaultConfig {
diff --git a/packages/espresso/pubspec.yaml b/packages/espresso/pubspec.yaml
index ef0d6dd..0dffbdb 100644
--- a/packages/espresso/pubspec.yaml
+++ b/packages/espresso/pubspec.yaml
@@ -3,7 +3,7 @@
Allows driving Flutter widgets from a native Espresso test.
repository: https://github.com/flutter/packages/tree/main/packages/espresso
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+espresso%22
-version: 0.3.0+3
+version: 0.3.0+4
environment:
sdk: ">=2.17.0 <4.0.0"
diff --git a/packages/flutter_plugin_android_lifecycle/CHANGELOG.md b/packages/flutter_plugin_android_lifecycle/CHANGELOG.md
index ca354c8..1e1e031 100644
--- a/packages/flutter_plugin_android_lifecycle/CHANGELOG.md
+++ b/packages/flutter_plugin_android_lifecycle/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 2.0.13
+
+* Fixes compatibility with AGP versions older than 4.2.
+
## 2.0.12
* Adds `targetCompatibilty` matching `sourceCompatibility` for older toolchains.
diff --git a/packages/flutter_plugin_android_lifecycle/android/build.gradle b/packages/flutter_plugin_android_lifecycle/android/build.gradle
index 1203eb3..5a19330 100644
--- a/packages/flutter_plugin_android_lifecycle/android/build.gradle
+++ b/packages/flutter_plugin_android_lifecycle/android/build.gradle
@@ -22,7 +22,10 @@
apply plugin: 'com.android.library'
android {
- namespace 'io.flutter.plugins.flutter_plugin_android_lifecycle'
+ // Conditional for compatibility with AGP <4.2.
+ if (project.android.hasProperty("namespace")) {
+ namespace 'io.flutter.plugins.flutter_plugin_android_lifecycle'
+ }
compileSdkVersion 33
defaultConfig {
diff --git a/packages/flutter_plugin_android_lifecycle/pubspec.yaml b/packages/flutter_plugin_android_lifecycle/pubspec.yaml
index d76dabd..fd111c2 100644
--- a/packages/flutter_plugin_android_lifecycle/pubspec.yaml
+++ b/packages/flutter_plugin_android_lifecycle/pubspec.yaml
@@ -2,7 +2,7 @@
description: Flutter plugin for accessing an Android Lifecycle within other plugins.
repository: https://github.com/flutter/packages/tree/main/packages/flutter_plugin_android_lifecycle
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+flutter_plugin_android_lifecycle%22
-version: 2.0.12
+version: 2.0.13
environment:
sdk: ">=2.17.0 <4.0.0"
diff --git a/packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md
index 0e91f2d..c61f156 100644
--- a/packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md
+++ b/packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 2.4.13
+
+* Fixes compatibility with AGP versions older than 4.2.
+
## 2.4.12
* Fixes Java warnings.
diff --git a/packages/google_maps_flutter/google_maps_flutter_android/android/build.gradle b/packages/google_maps_flutter/google_maps_flutter_android/android/build.gradle
index 35ba284..42e05a7 100644
--- a/packages/google_maps_flutter/google_maps_flutter_android/android/build.gradle
+++ b/packages/google_maps_flutter/google_maps_flutter_android/android/build.gradle
@@ -22,7 +22,10 @@
apply plugin: 'com.android.library'
android {
- namespace 'io.flutter.plugins.googlemaps'
+ // Conditional for compatibility with AGP <4.2.
+ if (project.android.hasProperty("namespace")) {
+ namespace 'io.flutter.plugins.googlemaps'
+ }
compileSdkVersion 33
defaultConfig {
diff --git a/packages/google_maps_flutter/google_maps_flutter_android/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_android/pubspec.yaml
index 0391470..71ba774 100644
--- a/packages/google_maps_flutter/google_maps_flutter_android/pubspec.yaml
+++ b/packages/google_maps_flutter/google_maps_flutter_android/pubspec.yaml
@@ -2,7 +2,7 @@
description: Android implementation of the google_maps_flutter plugin.
repository: https://github.com/flutter/packages/tree/main/packages/google_maps_flutter/google_maps_flutter_android
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22
-version: 2.4.12
+version: 2.4.13
environment:
sdk: ">=2.17.0 <4.0.0"
diff --git a/packages/google_sign_in/google_sign_in_android/CHANGELOG.md b/packages/google_sign_in/google_sign_in_android/CHANGELOG.md
index d9082a6..7aeafc1 100644
--- a/packages/google_sign_in/google_sign_in_android/CHANGELOG.md
+++ b/packages/google_sign_in/google_sign_in_android/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 6.1.14
+
+* Fixes compatibility with AGP versions older than 4.2.
+
## 6.1.13
* Adds `targetCompatibilty` matching `sourceCompatibility` for older toolchains.
diff --git a/packages/google_sign_in/google_sign_in_android/android/build.gradle b/packages/google_sign_in/google_sign_in_android/android/build.gradle
index 72c383c..e48223d 100644
--- a/packages/google_sign_in/google_sign_in_android/android/build.gradle
+++ b/packages/google_sign_in/google_sign_in_android/android/build.gradle
@@ -22,7 +22,10 @@
apply plugin: 'com.android.library'
android {
- namespace 'io.flutter.plugins.googlesignin'
+ // Conditional for compatibility with AGP <4.2.
+ if (project.android.hasProperty("namespace")) {
+ namespace 'io.flutter.plugins.googlesignin'
+ }
compileSdkVersion 33
defaultConfig {
diff --git a/packages/google_sign_in/google_sign_in_android/pubspec.yaml b/packages/google_sign_in/google_sign_in_android/pubspec.yaml
index 1ff448e..7390474 100644
--- a/packages/google_sign_in/google_sign_in_android/pubspec.yaml
+++ b/packages/google_sign_in/google_sign_in_android/pubspec.yaml
@@ -2,7 +2,7 @@
description: Android implementation of the google_sign_in plugin.
repository: https://github.com/flutter/packages/tree/main/packages/google_sign_in/google_sign_in_android
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+google_sign_in%22
-version: 6.1.13
+version: 6.1.14
environment:
sdk: ">=2.17.0 <4.0.0"
diff --git a/packages/image_picker/image_picker_android/CHANGELOG.md b/packages/image_picker/image_picker_android/CHANGELOG.md
index 5128172..44902aa 100644
--- a/packages/image_picker/image_picker_android/CHANGELOG.md
+++ b/packages/image_picker/image_picker_android/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.8.6+9
+
+* Fixes compatibility with AGP versions older than 4.2.
+
## 0.8.6+8
* Adds a namespace for compatibility with AGP 8.0.
diff --git a/packages/image_picker/image_picker_android/android/build.gradle b/packages/image_picker/image_picker_android/android/build.gradle
index 777a4e4..08b4bb3 100644
--- a/packages/image_picker/image_picker_android/android/build.gradle
+++ b/packages/image_picker/image_picker_android/android/build.gradle
@@ -22,7 +22,10 @@
apply plugin: 'com.android.library'
android {
- namespace 'io.flutter.plugins.imagepicker'
+ // Conditional for compatibility with AGP <4.2.
+ if (project.android.hasProperty("namespace")) {
+ namespace 'io.flutter.plugins.imagepicker'
+ }
compileSdkVersion 33
defaultConfig {
diff --git a/packages/image_picker/image_picker_android/pubspec.yaml b/packages/image_picker/image_picker_android/pubspec.yaml
index 349cacc..e95d14c 100755
--- a/packages/image_picker/image_picker_android/pubspec.yaml
+++ b/packages/image_picker/image_picker_android/pubspec.yaml
@@ -3,7 +3,7 @@
repository: https://github.com/flutter/packages/tree/main/packages/image_picker/image_picker_android
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+image_picker%22
-version: 0.8.6+8
+version: 0.8.6+9
environment:
sdk: ">=2.18.0 <4.0.0"
diff --git a/packages/in_app_purchase/in_app_purchase_android/CHANGELOG.md b/packages/in_app_purchase/in_app_purchase_android/CHANGELOG.md
index 1348347..8f1131b 100644
--- a/packages/in_app_purchase/in_app_purchase_android/CHANGELOG.md
+++ b/packages/in_app_purchase/in_app_purchase_android/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.2.5+4
+
+* Fixes compatibility with AGP versions older than 4.2.
+
## 0.2.5+3
* Updates com.android.billingclient:billing from 5.1.0 to 5.2.0.
diff --git a/packages/in_app_purchase/in_app_purchase_android/android/build.gradle b/packages/in_app_purchase/in_app_purchase_android/android/build.gradle
index 2892be2..94acf3a 100644
--- a/packages/in_app_purchase/in_app_purchase_android/android/build.gradle
+++ b/packages/in_app_purchase/in_app_purchase_android/android/build.gradle
@@ -22,7 +22,10 @@
apply plugin: 'com.android.library'
android {
- namespace 'io.flutter.plugins.inapppurchase'
+ // Conditional for compatibility with AGP <4.2.
+ if (project.android.hasProperty("namespace")) {
+ namespace 'io.flutter.plugins.inapppurchase'
+ }
compileSdkVersion 33
defaultConfig {
diff --git a/packages/in_app_purchase/in_app_purchase_android/pubspec.yaml b/packages/in_app_purchase/in_app_purchase_android/pubspec.yaml
index f813111..96426db 100644
--- a/packages/in_app_purchase/in_app_purchase_android/pubspec.yaml
+++ b/packages/in_app_purchase/in_app_purchase_android/pubspec.yaml
@@ -2,7 +2,7 @@
description: An implementation for the Android platform of the Flutter `in_app_purchase` plugin. This uses the Android BillingClient APIs.
repository: https://github.com/flutter/packages/tree/main/packages/in_app_purchase/in_app_purchase_android
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+in_app_purchase%22
-version: 0.2.5+3
+version: 0.2.5+4
environment:
sdk: ">=2.18.0 <4.0.0"
diff --git a/packages/local_auth/local_auth_android/CHANGELOG.md b/packages/local_auth/local_auth_android/CHANGELOG.md
index 1f65132..6752fc5 100644
--- a/packages/local_auth/local_auth_android/CHANGELOG.md
+++ b/packages/local_auth/local_auth_android/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 1.0.27
+
+* Fixes compatibility with AGP versions older than 4.2.
+
## 1.0.26
* Adds `targetCompatibilty` matching `sourceCompatibility` for older toolchains.
diff --git a/packages/local_auth/local_auth_android/android/build.gradle b/packages/local_auth/local_auth_android/android/build.gradle
index a212f23..6c1dc9c 100644
--- a/packages/local_auth/local_auth_android/android/build.gradle
+++ b/packages/local_auth/local_auth_android/android/build.gradle
@@ -22,7 +22,10 @@
apply plugin: 'com.android.library'
android {
- namespace 'io.flutter.plugins.localauth'
+ // Conditional for compatibility with AGP <4.2.
+ if (project.android.hasProperty("namespace")) {
+ namespace 'io.flutter.plugins.localauth'
+ }
compileSdkVersion 33
defaultConfig {
diff --git a/packages/local_auth/local_auth_android/pubspec.yaml b/packages/local_auth/local_auth_android/pubspec.yaml
index d9cf8df..a1843ec 100644
--- a/packages/local_auth/local_auth_android/pubspec.yaml
+++ b/packages/local_auth/local_auth_android/pubspec.yaml
@@ -2,7 +2,7 @@
description: Android implementation of the local_auth plugin.
repository: https://github.com/flutter/packages/tree/main/packages/local_auth/local_auth_android
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+local_auth%22
-version: 1.0.26
+version: 1.0.27
environment:
sdk: ">=2.17.0 <4.0.0"
diff --git a/packages/path_provider/path_provider_android/CHANGELOG.md b/packages/path_provider/path_provider_android/CHANGELOG.md
index 660b3fa..5f55141 100644
--- a/packages/path_provider/path_provider_android/CHANGELOG.md
+++ b/packages/path_provider/path_provider_android/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 2.0.27
+
+* Fixes compatibility with AGP versions older than 4.2.
+
## 2.0.26
* Adds a namespace for compatibility with AGP 8.0.
diff --git a/packages/path_provider/path_provider_android/android/build.gradle b/packages/path_provider/path_provider_android/android/build.gradle
index 09b407a..0cdb3d0 100644
--- a/packages/path_provider/path_provider_android/android/build.gradle
+++ b/packages/path_provider/path_provider_android/android/build.gradle
@@ -22,7 +22,10 @@
apply plugin: 'com.android.library'
android {
- namespace 'io.flutter.plugins.pathprovider'
+ // Conditional for compatibility with AGP <4.2.
+ if (project.android.hasProperty("namespace")) {
+ namespace 'io.flutter.plugins.pathprovider'
+ }
compileSdkVersion 33
defaultConfig {
diff --git a/packages/path_provider/path_provider_android/pubspec.yaml b/packages/path_provider/path_provider_android/pubspec.yaml
index 95300b1..f22706b 100644
--- a/packages/path_provider/path_provider_android/pubspec.yaml
+++ b/packages/path_provider/path_provider_android/pubspec.yaml
@@ -2,7 +2,7 @@
description: Android implementation of the path_provider plugin.
repository: https://github.com/flutter/packages/tree/main/packages/path_provider/path_provider_android
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+path_provider%22
-version: 2.0.26
+version: 2.0.27
environment:
sdk: ">=2.17.0 <4.0.0"
diff --git a/packages/pigeon/platform_tests/alternate_language_test_plugin/android/build.gradle b/packages/pigeon/platform_tests/alternate_language_test_plugin/android/build.gradle
index 8f4a155..a6a5027 100644
--- a/packages/pigeon/platform_tests/alternate_language_test_plugin/android/build.gradle
+++ b/packages/pigeon/platform_tests/alternate_language_test_plugin/android/build.gradle
@@ -22,7 +22,10 @@
apply plugin: 'com.android.library'
android {
- namespace 'com.example.alternate_language_test_plugin'
+ // Conditional for compatibility with AGP <4.2.
+ if (project.android.hasProperty("namespace")) {
+ namespace 'com.example.alternate_language_test_plugin'
+ }
compileSdkVersion 33
compileOptions {
diff --git a/packages/pigeon/platform_tests/test_plugin/android/build.gradle b/packages/pigeon/platform_tests/test_plugin/android/build.gradle
index 6ee629b..e99796f 100644
--- a/packages/pigeon/platform_tests/test_plugin/android/build.gradle
+++ b/packages/pigeon/platform_tests/test_plugin/android/build.gradle
@@ -25,7 +25,10 @@
apply plugin: 'kotlin-android'
android {
- namespace 'com.example.test_plugin'
+ // Conditional for compatibility with AGP <4.2.
+ if (project.android.hasProperty("namespace")) {
+ namespace 'com.example.test_plugin'
+ }
compileSdkVersion 33
compileOptions {
diff --git a/packages/quick_actions/quick_actions_android/CHANGELOG.md b/packages/quick_actions/quick_actions_android/CHANGELOG.md
index 3187f6a..32a0fa1 100644
--- a/packages/quick_actions/quick_actions_android/CHANGELOG.md
+++ b/packages/quick_actions/quick_actions_android/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 1.0.4
+
+* Fixes compatibility with AGP versions older than 4.2.
+
## 1.0.3
* Adds a namespace for compatibility with AGP 8.0.
diff --git a/packages/quick_actions/quick_actions_android/android/build.gradle b/packages/quick_actions/quick_actions_android/android/build.gradle
index 935c517..71bd5b2 100644
--- a/packages/quick_actions/quick_actions_android/android/build.gradle
+++ b/packages/quick_actions/quick_actions_android/android/build.gradle
@@ -22,7 +22,10 @@
apply plugin: 'com.android.library'
android {
- namespace 'io.flutter.plugins.quickactions'
+ // Conditional for compatibility with AGP <4.2.
+ if (project.android.hasProperty("namespace")) {
+ namespace 'io.flutter.plugins.quickactions'
+ }
compileSdkVersion 33
defaultConfig {
diff --git a/packages/quick_actions/quick_actions_android/pubspec.yaml b/packages/quick_actions/quick_actions_android/pubspec.yaml
index ca16d8b..65f71d6 100644
--- a/packages/quick_actions/quick_actions_android/pubspec.yaml
+++ b/packages/quick_actions/quick_actions_android/pubspec.yaml
@@ -2,7 +2,7 @@
description: An implementation for the Android platform of the Flutter `quick_actions` plugin.
repository: https://github.com/flutter/packages/tree/main/packages/quick_actions/quick_actions_android
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+in_app_purchase%22
-version: 1.0.3
+version: 1.0.4
environment:
sdk: ">=2.17.0 <4.0.0"
diff --git a/packages/shared_preferences/shared_preferences_android/CHANGELOG.md b/packages/shared_preferences/shared_preferences_android/CHANGELOG.md
index a14bc1d..e901898 100644
--- a/packages/shared_preferences/shared_preferences_android/CHANGELOG.md
+++ b/packages/shared_preferences/shared_preferences_android/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 2.1.4
+
+* Fixes compatibility with AGP versions older than 4.2.
+
## 2.1.3
* Adds a namespace for compatibility with AGP 8.0.
diff --git a/packages/shared_preferences/shared_preferences_android/android/build.gradle b/packages/shared_preferences/shared_preferences_android/android/build.gradle
index 4469e49..f3074dd 100644
--- a/packages/shared_preferences/shared_preferences_android/android/build.gradle
+++ b/packages/shared_preferences/shared_preferences_android/android/build.gradle
@@ -30,7 +30,10 @@
apply plugin: 'com.android.library'
android {
- namespace 'io.flutter.plugins.sharedpreferences'
+ // Conditional for compatibility with AGP <4.2.
+ if (project.android.hasProperty("namespace")) {
+ namespace 'io.flutter.plugins.sharedpreferences'
+ }
compileSdkVersion 33
compileOptions {
diff --git a/packages/shared_preferences/shared_preferences_android/pubspec.yaml b/packages/shared_preferences/shared_preferences_android/pubspec.yaml
index e9381f4..b8d240a 100644
--- a/packages/shared_preferences/shared_preferences_android/pubspec.yaml
+++ b/packages/shared_preferences/shared_preferences_android/pubspec.yaml
@@ -2,7 +2,7 @@
description: Android implementation of the shared_preferences plugin
repository: https://github.com/flutter/packages/tree/main/packages/shared_preferences/shared_preferences_android
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+shared_preferences%22
-version: 2.1.3
+version: 2.1.4
environment:
sdk: ">=2.17.0 <4.0.0"
diff --git a/packages/url_launcher/url_launcher_android/CHANGELOG.md b/packages/url_launcher/url_launcher_android/CHANGELOG.md
index fdf4eb9..aa82c4b 100644
--- a/packages/url_launcher/url_launcher_android/CHANGELOG.md
+++ b/packages/url_launcher/url_launcher_android/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 6.0.31
+
+* Fixes compatibility with AGP versions older than 4.2.
+
## 6.0.30
* Adds `targetCompatibilty` matching `sourceCompatibility` for older toolchains.
diff --git a/packages/url_launcher/url_launcher_android/android/build.gradle b/packages/url_launcher/url_launcher_android/android/build.gradle
index e0c2fc6..3344266 100644
--- a/packages/url_launcher/url_launcher_android/android/build.gradle
+++ b/packages/url_launcher/url_launcher_android/android/build.gradle
@@ -22,7 +22,10 @@
apply plugin: 'com.android.library'
android {
- namespace 'io.flutter.plugins.urllauncher'
+ // Conditional for compatibility with AGP <4.2.
+ if (project.android.hasProperty("namespace")) {
+ namespace 'io.flutter.plugins.urllauncher'
+ }
compileSdkVersion 33
defaultConfig {
diff --git a/packages/url_launcher/url_launcher_android/pubspec.yaml b/packages/url_launcher/url_launcher_android/pubspec.yaml
index cf35a0b..73a427d 100644
--- a/packages/url_launcher/url_launcher_android/pubspec.yaml
+++ b/packages/url_launcher/url_launcher_android/pubspec.yaml
@@ -2,7 +2,7 @@
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.0.30
+version: 6.0.31
environment:
sdk: ">=2.18.0 <4.0.0"
diff --git a/packages/video_player/video_player_android/CHANGELOG.md b/packages/video_player/video_player_android/CHANGELOG.md
index 3a60162..a204cb2 100644
--- a/packages/video_player/video_player_android/CHANGELOG.md
+++ b/packages/video_player/video_player_android/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 2.4.6
+
+* Fixes compatibility with AGP versions older than 4.2.
+
## 2.4.5
* Adds a namespace for compatibility with AGP 8.0.
diff --git a/packages/video_player/video_player_android/android/build.gradle b/packages/video_player/video_player_android/android/build.gradle
index 0facb26..613b8ed 100644
--- a/packages/video_player/video_player_android/android/build.gradle
+++ b/packages/video_player/video_player_android/android/build.gradle
@@ -27,7 +27,10 @@
apply plugin: 'com.android.library'
android {
- namespace 'io.flutter.plugins.videoplayer'
+ // Conditional for compatibility with AGP <4.2.
+ if (project.android.hasProperty("namespace")) {
+ namespace 'io.flutter.plugins.videoplayer'
+ }
compileSdkVersion 33
defaultConfig {
diff --git a/packages/video_player/video_player_android/pubspec.yaml b/packages/video_player/video_player_android/pubspec.yaml
index 7940829..dc195b4 100644
--- a/packages/video_player/video_player_android/pubspec.yaml
+++ b/packages/video_player/video_player_android/pubspec.yaml
@@ -2,7 +2,7 @@
description: Android implementation of the video_player plugin.
repository: https://github.com/flutter/packages/tree/main/packages/video_player/video_player_android
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+video_player%22
-version: 2.4.5
+version: 2.4.6
environment:
sdk: ">=2.18.0 <4.0.0"
diff --git a/packages/webview_flutter/webview_flutter_android/CHANGELOG.md b/packages/webview_flutter/webview_flutter_android/CHANGELOG.md
index 137f882..02edbab 100644
--- a/packages/webview_flutter/webview_flutter_android/CHANGELOG.md
+++ b/packages/webview_flutter/webview_flutter_android/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 3.6.2
+
+* Fixes compatibility with AGP versions older than 4.2.
+
## 3.6.1
* Adds a namespace for compatibility with AGP 8.0.
diff --git a/packages/webview_flutter/webview_flutter_android/android/build.gradle b/packages/webview_flutter/webview_flutter_android/android/build.gradle
index 13eff1a..f3da461 100644
--- a/packages/webview_flutter/webview_flutter_android/android/build.gradle
+++ b/packages/webview_flutter/webview_flutter_android/android/build.gradle
@@ -22,7 +22,10 @@
apply plugin: 'com.android.library'
android {
- namespace 'io.flutter.plugins.webviewflutter'
+ // Conditional for compatibility with AGP <4.2.
+ if (project.android.hasProperty("namespace")) {
+ namespace 'io.flutter.plugins.webviewflutter'
+ }
compileSdkVersion 33
defaultConfig {
diff --git a/packages/webview_flutter/webview_flutter_android/pubspec.yaml b/packages/webview_flutter/webview_flutter_android/pubspec.yaml
index 94105ff..8196b3b 100644
--- a/packages/webview_flutter/webview_flutter_android/pubspec.yaml
+++ b/packages/webview_flutter/webview_flutter_android/pubspec.yaml
@@ -2,7 +2,7 @@
description: A Flutter plugin that provides a WebView widget on Android.
repository: https://github.com/flutter/packages/tree/main/packages/webview_flutter/webview_flutter_android
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+webview%22
-version: 3.6.1
+version: 3.6.2
environment:
sdk: ">=2.18.0 <4.0.0"
diff --git a/script/tool/lib/src/gradle_check_command.dart b/script/tool/lib/src/gradle_check_command.dart
index a3a1e76..09a9d7a 100644
--- a/script/tool/lib/src/gradle_check_command.dart
+++ b/script/tool/lib/src/gradle_check_command.dart
@@ -153,13 +153,32 @@
RegExp('^\\s*namespace\\s+[\'"](.*?)[\'"]', multiLine: true);
final RegExpMatch? namespaceMatch =
namespaceRegex.firstMatch(gradleContents);
+
+ // For plugins, make sure the namespace is conditionalized so that it
+ // doesn't break client apps using AGP 4.1 and earlier (which don't have
+ // a namespace property, and will fail to build if it's set).
+ const String namespaceConditional =
+ 'if (project.android.hasProperty("namespace"))';
+ String exampleSetNamespace = "namespace 'dev.flutter.foo'";
+ if (!isExample) {
+ exampleSetNamespace = '''
+$namespaceConditional {
+ $exampleSetNamespace
+}''';
+ }
+ // Wrap the namespace command in an `android` block, adding the indentation
+ // to make it line up correctly.
+ final String exampleAndroidNamespaceBlock = '''
+ android {
+ ${exampleSetNamespace.split('\n').join('\n ')}
+ }
+''';
+
if (namespaceMatch == null) {
- const String errorMessage = '''
+ final String errorMessage = '''
build.gradle must set a "namespace":
- android {
- namespace 'dev.flutter.foo'
- }
+$exampleAndroidNamespaceBlock
The value must match the "package" attribute in AndroidManifest.xml, if one is
present. For more information, see:
@@ -170,6 +189,18 @@
'$indentation${errorMessage.split('\n').join('\n$indentation')}');
return false;
} else {
+ if (!isExample && !gradleContents.contains(namespaceConditional)) {
+ final String errorMessage = '''
+build.gradle for a plugin must conditionalize "namespace":
+
+$exampleAndroidNamespaceBlock
+''';
+
+ printError(
+ '$indentation${errorMessage.split('\n').join('\n$indentation')}');
+ return false;
+ }
+
return _validateNamespaceMatchesManifest(package,
isExample: isExample, namespace: namespaceMatch.group(1)!);
}
diff --git a/script/tool/test/gradle_check_command_test.dart b/script/tool/test/gradle_check_command_test.dart
index e72d3f8..68581c7 100644
--- a/script/tool/test/gradle_check_command_test.dart
+++ b/script/tool/test/gradle_check_command_test.dart
@@ -41,6 +41,7 @@
bool includeTargetCompat = false,
bool commentSourceLanguage = false,
bool includeNamespace = true,
+ bool conditionalizeNamespace = true,
bool commentNamespace = false,
bool warningsConfigured = true,
}) {
@@ -69,8 +70,15 @@
'${commentSourceLanguage ? '// ' : ''}sourceCompatibility JavaVersion.VERSION_1_8';
final String targetCompat =
'${commentSourceLanguage ? '// ' : ''}targetCompatibility JavaVersion.VERSION_1_8';
- final String namespace =
- "${commentNamespace ? '// ' : ''}namespace '$_defaultFakeNamespace'";
+ String namespace =
+ " ${commentNamespace ? '// ' : ''}namespace '$_defaultFakeNamespace'";
+ if (conditionalizeNamespace) {
+ namespace = '''
+ if (project.android.hasProperty("namespace")) {
+ $namespace
+ }
+''';
+ }
buildGradle.writeAsStringSync('''
group 'dev.flutter.plugins.fake'
@@ -87,7 +95,7 @@
${includeLanguageVersion ? javaSection : ''}
android {
- ${includeNamespace ? namespace : ''}
+${includeNamespace ? namespace : ''}
compileSdkVersion 33
defaultConfig {
@@ -435,6 +443,28 @@
);
});
+ test('fails when plugin namespace is not conditional', () async {
+ final RepositoryPackage package =
+ createFakePlugin('a_plugin', packagesDir, examples: <String>[]);
+ writeFakePluginBuildGradle(package,
+ includeLanguageVersion: true, conditionalizeNamespace: false);
+ writeFakeManifest(package);
+
+ Error? commandError;
+ final List<String> output = await runCapturingPrint(
+ runner, <String>['gradle-check'], errorHandler: (Error e) {
+ commandError = e;
+ });
+
+ expect(commandError, isA<ToolExit>());
+ expect(
+ output,
+ containsAllInOrder(<Matcher>[
+ contains('build.gradle for a plugin must conditionalize "namespace"'),
+ ]),
+ );
+ });
+
test('fails when namespace is missing', () async {
final RepositoryPackage package =
createFakePlugin('a_plugin', packagesDir, examples: <String>[]);