From c1679a4cea57dc8c3eaa00005d657c8213100105 Mon Sep 17 00:00:00 2001 From: sunnylqm Date: Wed, 20 Dec 2023 10:37:43 +0800 Subject: [PATCH] fix: support gradle namespace --- android/build.gradle | 23 +++++++++++++++++++++++ android/src/main/AndroidManifest.xml | 1 - android/src/main/AndroidManifestNew.xml | 14 ++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 android/src/main/AndroidManifestNew.xml diff --git a/android/build.gradle b/android/build.gradle index 8e21cd2..c0a028f 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -9,6 +9,19 @@ def isNewArchitectureEnabled() { return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true" } +def supportsNamespace() { + def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.') + def major = parsed[0].toInteger() + def minor = parsed[1].toInteger() + + // Namespace support was added in 7.3.0 + if (major == 7 && minor >= 3) { + return true + } + + return major >= 8 +} + apply plugin: 'com.android.library' if (isNewArchitectureEnabled()) { apply plugin: 'com.facebook.react' @@ -16,6 +29,16 @@ if (isNewArchitectureEnabled()) { android { + + if (supportsNamespace()) { + namespace "cn.reactnative.modules.update" + + sourceSets { + main { + manifest.srcFile "src/main/AndroidManifestNew.xml" + } + } + } compileSdkVersion safeExtGet('compileSdkVersion', 28) buildToolsVersion safeExtGet('buildToolsVersion', '28.0.3') diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml index 9877142..dbaa731 100644 --- a/android/src/main/AndroidManifest.xml +++ b/android/src/main/AndroidManifest.xml @@ -1,4 +1,3 @@ - diff --git a/android/src/main/AndroidManifestNew.xml b/android/src/main/AndroidManifestNew.xml new file mode 100644 index 0000000..13ec9b3 --- /dev/null +++ b/android/src/main/AndroidManifestNew.xml @@ -0,0 +1,14 @@ + + + + + + + +