Remove conditionality in templates that was for AGP <= 4.2 support (#151845)

Not needed after https://github.com/flutter/flutter/pull/149204 (as long as nothing has changed since the comment was made 🙂).

Fixes https://github.com/flutter/flutter/issues/145105.
This commit is contained in:
Gray Mackall 2024-07-16 15:33:24 -07:00 committed by GitHub
parent 6e189a7452
commit 8c5fbb4021
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 3 additions and 28 deletions

View File

@ -24,11 +24,7 @@ apply plugin: "com.android.library"
apply plugin: "kotlin-android" apply plugin: "kotlin-android"
android { android {
// Conditional for compatibility with AGP <4.2. namespace = "{{androidIdentifier}}"
if (project.android.hasProperty("namespace")) {
namespace = "{{androidIdentifier}}"
}
compileSdk = {{compileSdkVersion}} compileSdk = {{compileSdkVersion}}
defaultConfig { defaultConfig {
minSdk = {{minSdkVersion}} minSdk = {{minSdkVersion}}

View File

@ -3,11 +3,7 @@ def flutterPluginVersion = "managed"
apply plugin: "com.android.application" apply plugin: "com.android.application"
android { android {
// Conditional for compatibility with AGP <4.2. namespace = "{{androidIdentifier}}.host"
if (project.android.hasProperty("namespace")) {
namespace = "{{androidIdentifier}}.host"
}
compileSdk = {{compileSdkVersion}} compileSdk = {{compileSdkVersion}}
compileOptions { compileOptions {

View File

@ -30,11 +30,7 @@ group = "{{androidIdentifier}}"
version = "1.0" version = "1.0"
android { android {
// Conditional for compatibility with AGP <4.2. namespace = "{{androidIdentifier}}"
if (project.android.hasProperty("namespace")) {
namespace = "{{androidIdentifier}}"
}
compileSdk = flutter.compileSdkVersion compileSdk = flutter.compileSdkVersion
ndkVersion = flutter.ndkVersion ndkVersion = flutter.ndkVersion

View File

@ -3054,8 +3054,6 @@ void main() {
final String buildGradleContent = await buildGradleFile.readAsString(); final String buildGradleContent = await buildGradleFile.readAsString();
expect(buildGradleContent.contains('namespace = "com.bar.foo.flutter_project"'), true); expect(buildGradleContent.contains('namespace = "com.bar.foo.flutter_project"'), true);
// The namespace should be conditionalized for AGP <4.2.
expect(buildGradleContent.contains('if (project.android.hasProperty("namespace")) {'), true);
}); });
testUsingContext('Android FFI plugin contains namespace', () async { testUsingContext('Android FFI plugin contains namespace', () async {
@ -3077,8 +3075,6 @@ void main() {
final String buildGradleContent = await buildGradleFile.readAsString(); final String buildGradleContent = await buildGradleFile.readAsString();
expect(buildGradleContent.contains('namespace = "com.bar.foo.flutter_project"'), true); expect(buildGradleContent.contains('namespace = "com.bar.foo.flutter_project"'), true);
// The namespace should be conditionalized for AGP <4.2.
expect(buildGradleContent.contains('if (project.android.hasProperty("namespace")) {'), true);
}); });
testUsingContext('Android Kotlin plugin contains namespace', () async { testUsingContext('Android Kotlin plugin contains namespace', () async {
@ -3101,8 +3097,6 @@ void main() {
final String buildGradleContent = await buildGradleFile.readAsString(); final String buildGradleContent = await buildGradleFile.readAsString();
expect(buildGradleContent.contains('namespace = "com.bar.foo.flutter_project"'), true); expect(buildGradleContent.contains('namespace = "com.bar.foo.flutter_project"'), true);
// The namespace should be conditionalized for AGP <4.2.
expect(buildGradleContent.contains('if (project.android.hasProperty("namespace")) {'), true);
}); });
testUsingContext('Flutter module Android project contains namespace', () async { testUsingContext('Flutter module Android project contains namespace', () async {
@ -3128,13 +3122,6 @@ void main() {
expect(moduleFlutterBuildGradleFileContent.contains(expectedNameSpace), true); expect(moduleFlutterBuildGradleFileContent.contains(expectedNameSpace), true);
const String expectedHostNameSpace = 'namespace = "com.bar.foo.flutter_project.host"'; const String expectedHostNameSpace = 'namespace = "com.bar.foo.flutter_project.host"';
expect(moduleAppBuildGradleFileContent.contains(expectedHostNameSpace), true); expect(moduleAppBuildGradleFileContent.contains(expectedHostNameSpace), true);
// The namespaces should be conditionalized for AGP <4.2.
const String expectedConditional = 'if (project.android.hasProperty("namespace")) {';
expect(moduleBuildGradleFileContent.contains(expectedConditional), true);
expect(moduleAppBuildGradleFileContent.contains(expectedConditional), true);
expect(moduleFlutterBuildGradleFileContent.contains(expectedConditional), true);
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
Pub: () => Pub.test( Pub: () => Pub.test(
fileSystem: globals.fs, fileSystem: globals.fs,