Skip to content

Commit a86beaf

Browse files
[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 flutter/flutter#125621
1 parent 2047645 commit a86beaf

File tree

47 files changed

+206
-38
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+206
-38
lines changed

packages/camera/camera_android/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.10.6+2
2+
3+
* Fixes compatibility with AGP versions older than 4.2.
4+
15
## 0.10.6+1
26

37
* Adds a namespace for compatibility with AGP 8.0.

packages/camera/camera_android/android/build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ project.getTasks().withType(JavaCompile){
2727
apply plugin: 'com.android.library'
2828

2929
android {
30-
namespace 'io.flutter.plugins.camera'
30+
// Conditional for compatibility with AGP <4.2.
31+
if (project.android.hasProperty("namespace")) {
32+
namespace 'io.flutter.plugins.camera'
33+
}
3134
compileSdkVersion 33
3235

3336
defaultConfig {

packages/camera/camera_android/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: camera_android
22
description: Android implementation of the camera plugin.
33
repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_android
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
5-
version: 0.10.6+1
5+
version: 0.10.6+2
66

77
environment:
88
sdk: ">=2.17.0 <4.0.0"

packages/camera/camera_android_camerax/android/build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ rootProject.allprojects {
2222
apply plugin: 'com.android.library'
2323

2424
android {
25-
namespace 'io.flutter.plugins.camerax'
25+
// Conditional for compatibility with AGP <4.2.
26+
if (project.android.hasProperty("namespace")) {
27+
namespace 'io.flutter.plugins.camerax'
28+
}
2629
// CameraX dependencies require compilation against version 33 or later.
2730
compileSdkVersion 33
2831

packages/espresso/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.3.0+4
2+
3+
* Fixes compatibility with AGP versions older than 4.2.
4+
15
## 0.3.0+3
26

37
* Adds `targetCompatibilty` matching `sourceCompatibility` for older toolchains.

packages/espresso/android/build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ rootProject.allprojects {
2222
apply plugin: 'com.android.library'
2323

2424
android {
25-
namespace 'com.example.espresso'
25+
// Conditional for compatibility with AGP <4.2.
26+
if (project.android.hasProperty("namespace")) {
27+
namespace 'com.example.espresso'
28+
}
2629
compileSdkVersion 33
2730

2831
defaultConfig {

packages/espresso/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: Java classes for testing Flutter apps using Espresso.
33
Allows driving Flutter widgets from a native Espresso test.
44
repository: https://github.com/flutter/packages/tree/main/packages/espresso
55
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+espresso%22
6-
version: 0.3.0+3
6+
version: 0.3.0+4
77

88
environment:
99
sdk: ">=2.17.0 <4.0.0"

packages/flutter_plugin_android_lifecycle/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.0.13
2+
3+
* Fixes compatibility with AGP versions older than 4.2.
4+
15
## 2.0.12
26

37
* Adds `targetCompatibilty` matching `sourceCompatibility` for older toolchains.

packages/flutter_plugin_android_lifecycle/android/build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ rootProject.allprojects {
2222
apply plugin: 'com.android.library'
2323

2424
android {
25-
namespace 'io.flutter.plugins.flutter_plugin_android_lifecycle'
25+
// Conditional for compatibility with AGP <4.2.
26+
if (project.android.hasProperty("namespace")) {
27+
namespace 'io.flutter.plugins.flutter_plugin_android_lifecycle'
28+
}
2629
compileSdkVersion 33
2730

2831
defaultConfig {

packages/flutter_plugin_android_lifecycle/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: flutter_plugin_android_lifecycle
22
description: Flutter plugin for accessing an Android Lifecycle within other plugins.
33
repository: https://github.com/flutter/packages/tree/main/packages/flutter_plugin_android_lifecycle
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+flutter_plugin_android_lifecycle%22
5-
version: 2.0.12
5+
version: 2.0.13
66

77
environment:
88
sdk: ">=2.17.0 <4.0.0"

0 commit comments

Comments
 (0)