Skip to content

Commit 45d4530

Browse files
ngocle2497troZeeatlj
authored
feat(android): 🌟 add support for React Native 0.73 (#736)
* feat(android): 🌟 add support for React Native 0.73 * Rollback AndroidManifest.xml to support RN <0.71 * feat(all): add namespace when ANDROID_GRADLE_PLUGIN_VERSION >=7 * Add support RN < 0.71 * Update android/build.gradle Co-authored-by: Burak Güner <[email protected]> --------- Co-authored-by: troZee <[email protected]> Co-authored-by: Burak Güner <[email protected]>
1 parent 5790904 commit 45d4530

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

android/build.gradle

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,32 @@ def getExtOrDefault(name) {
3333
def getExtOrIntegerDefault(name) {
3434
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['PagerView_' + name]).toInteger()
3535
}
36+
def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')[0].toInteger()
37+
def shouldUseNameSpace = agpVersion >= 8
38+
def PACKAGE_PROP = "package=\"com.reactnativepagerview\""
39+
def manifestOutFile = file("${projectDir}/src/main/AndroidManifest.xml")
40+
def manifestContent = manifestOutFile.getText()
41+
if(shouldUseNameSpace){
42+
manifestContent = manifestContent.replaceAll(
43+
PACKAGE_PROP,
44+
''
45+
)
46+
} else {
47+
if(!manifestContent.contains("$PACKAGE_PROP")){
48+
manifestContent = manifestContent.replace(
49+
'<manifest',
50+
"<manifest $PACKAGE_PROP "
51+
)
52+
}
53+
}
54+
manifestContent.replaceAll(" ", " ")
55+
manifestOutFile.write(manifestContent)
3656

3757
android {
3858
compileSdkVersion getExtOrIntegerDefault('compileSdkVersion')
39-
59+
if (shouldUseNameSpace){
60+
namespace = "com.reactnativepagerview"
61+
}
4062
defaultConfig {
4163
minSdkVersion getExtOrIntegerDefault('minSdkVersion')
4264
targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')

0 commit comments

Comments
 (0)