From f94c594d86c5001159edec1b526c05e9251c2be2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Taboulot?= Date: Mon, 29 Apr 2024 14:25:36 +0200 Subject: [PATCH] fix(android): handle namespace properly starting AGP 8 --- android/build.gradle | 12 +++++++++++- android/src/main/AndroidManifest.xml | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 4165d061..876b08a5 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -33,7 +33,17 @@ def getExtOrIntegerDefault(name) { android { compileSdkVersion getExtOrIntegerDefault("compileSdkVersion") - namespace "com.reactnativeimageresizer" + def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION + def agpMajorVersion = agpVersion.tokenize('.')[0].toInteger() + def agpMinorVersion = agpVersion.tokenize('.')[1].toInteger() + /** + * Namespace should be declared here starting from AGP 8.x, Starting AGP 7.3 it is also supported. + * For AGP < 7.3, namespace should be declared in AndroidManifest. + * See: https://developer.android.com/build/releases/past-releases/agp-8-0-0-release-notes#namespace-dsl + */ + if (agpMajorVersion >= 7 && agpMinorVersion >= 3) { + namespace "com.reactnativeimageresizer" + } defaultConfig { minSdkVersion getExtOrIntegerDefault("minSdkVersion") diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml index 0a0938ae..5c6a27fa 100644 --- a/android/src/main/AndroidManifest.xml +++ b/android/src/main/AndroidManifest.xml @@ -1,3 +1,3 @@ - +