Skip to content

Commit

Permalink
feat(all): add support RN <0.71 when add namespace (#197)
Browse files Browse the repository at this point in the history
* feat(android): 🌟 add support for React Native 0.73

* feat(android): add support RN <0.71 and RN 0.73
  • Loading branch information
ngocle2497 authored Oct 6, 2023
1 parent 86d70d1 commit 4cb35d9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
27 changes: 26 additions & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,34 @@ buildscript {

apply plugin: 'com.android.library'

def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')[0].toInteger()
def shouldUseNameSpace = agpVersion >= 7
def PACKAGE_PROP = "package=\"org.reactnative.maskedview\""
def manifestOutFile = file("${projectDir}/src/main/AndroidManifest.xml")
def manifestContent = manifestOutFile.getText()
if(shouldUseNameSpace){
manifestContent = manifestContent.replaceAll(
PACKAGE_PROP,
''
)
} else {
if(!manifestContent.contains("$PACKAGE_PROP")){
manifestContent = manifestContent.replace(
'<manifest',
"<manifest $PACKAGE_PROP "
)
}
}
manifestContent.replaceAll(" ", " ")
manifestOutFile.write(manifestContent)

android {
compileSdkVersion safeExtGet('compileSdkVersion', 28)
namespace = "org.reactnative.maskedview"

if(shouldUseNameSpace){
namespace = "org.reactnative.maskedview"
}

defaultConfig {
minSdkVersion safeExtGet('minSdkVersion', 16)
targetSdkVersion safeExtGet('targetSdkVersion', 28)
Expand Down
2 changes: 1 addition & 1 deletion android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<manifest package="org.reactnative.maskedview" xmlns:android="http://schemas.android.com/apk/res/android">
</manifest>

0 comments on commit 4cb35d9

Please sign in to comment.