Last active
November 8, 2023 16:36
-
-
Save satya164/e508e1be04650a68d76a993f5384ffd0 to your computer and use it in GitHub Desktop.
Android Gradle Plugin 8 support for React Native libraries
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/android/build.gradle b/android/build.gradle | |
index 525cb31..6af104d 100644 | |
--- a/android/build.gradle | |
+++ b/android/build.gradle | |
@@ -36,7 +36,30 @@ def getExtOrIntegerDefault(name) { | |
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["MyLib_" + name]).toInteger() | |
} | |
+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 | |
+ return (major == 7 && minor >= 3) || major >= 8 | |
+} | |
+ | |
android { | |
+ if (supportsNamespace()) { | |
+ namespace "com.mylib" | |
+ | |
+ sourceSets { | |
+ main { | |
+ manifest.srcFile "src/main/AndroidManifestNew.xml" | |
+ } | |
+ } | |
+ } | |
+ | |
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion") | |
defaultConfig { | |
diff --git a/android/src/main/AndroidManifestNew.xml b/android/src/main/AndroidManifestNew.xml | |
new file mode 100644 | |
index 0000000..a2f47b6 | |
--- /dev/null | |
+++ b/android/src/main/AndroidManifestNew.xml | |
@@ -0,0 +1,2 @@ | |
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | |
+</manifest> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment