Skip to content

Commit

Permalink
[various] Conditionalize the namespace in all Android plugins (#3836)
Browse files Browse the repository at this point in the history
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 flutter/flutter#125621
  • Loading branch information
stuartmorgan authored Apr 28, 2023
1 parent 2047645 commit a86beaf
Show file tree
Hide file tree
Showing 47 changed files with 206 additions and 38 deletions.
4 changes: 4 additions & 0 deletions packages/camera/camera_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
5 changes: 4 additions & 1 deletion packages/camera/camera_android/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ project.getTasks().withType(JavaCompile){
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 {
Expand Down
2 changes: 1 addition & 1 deletion packages/camera/camera_android/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: camera_android
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"
Expand Down
5 changes: 4 additions & 1 deletion packages/camera/camera_android_camerax/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ rootProject.allprojects {
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

Expand Down
4 changes: 4 additions & 0 deletions packages/espresso/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
5 changes: 4 additions & 1 deletion packages/espresso/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ rootProject.allprojects {
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 {
Expand Down
2 changes: 1 addition & 1 deletion packages/espresso/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Java classes for testing Flutter apps using Espresso.
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"
Expand Down
4 changes: 4 additions & 0 deletions packages/flutter_plugin_android_lifecycle/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ rootProject.allprojects {
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 {
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter_plugin_android_lifecycle/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: flutter_plugin_android_lifecycle
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"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.4.13

* Fixes compatibility with AGP versions older than 4.2.

## 2.4.12

* Fixes Java warnings.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ rootProject.allprojects {
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: google_maps_flutter_android
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"
Expand Down
4 changes: 4 additions & 0 deletions packages/google_sign_in/google_sign_in_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ rootProject.allprojects {
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: google_sign_in_android
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"
Expand Down
4 changes: 4 additions & 0 deletions packages/image_picker/image_picker_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ rootProject.allprojects {
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 {
Expand Down
2 changes: 1 addition & 1 deletion packages/image_picker/image_picker_android/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Android implementation of the image_picker plugin.
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"
Expand Down
4 changes: 4 additions & 0 deletions packages/in_app_purchase/in_app_purchase_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ rootProject.allprojects {
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: in_app_purchase_android
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"
Expand Down
4 changes: 4 additions & 0 deletions packages/local_auth/local_auth_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
5 changes: 4 additions & 1 deletion packages/local_auth/local_auth_android/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ rootProject.allprojects {
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 {
Expand Down
2 changes: 1 addition & 1 deletion packages/local_auth/local_auth_android/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: local_auth_android
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"
Expand Down
4 changes: 4 additions & 0 deletions packages/path_provider/path_provider_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ rootProject.allprojects {
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 {
Expand Down
2 changes: 1 addition & 1 deletion packages/path_provider/path_provider_android/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: path_provider_android
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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ rootProject.allprojects {
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ apply plugin: 'com.android.library'
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 {
Expand Down
4 changes: 4 additions & 0 deletions packages/quick_actions/quick_actions_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ rootProject.allprojects {
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 {
Expand Down
2 changes: 1 addition & 1 deletion packages/quick_actions/quick_actions_android/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: quick_actions_android
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"
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ allprojects {
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: shared_preferences_android
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"
Expand Down
4 changes: 4 additions & 0 deletions packages/url_launcher/url_launcher_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ rootProject.allprojects {
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 {
Expand Down
2 changes: 1 addition & 1 deletion packages/url_launcher/url_launcher_android/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.0.30
version: 6.0.31

environment:
sdk: ">=2.18.0 <4.0.0"
Expand Down
4 changes: 4 additions & 0 deletions packages/video_player/video_player_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Loading

0 comments on commit a86beaf

Please sign in to comment.