Skip to content

Commit

Permalink
feat(android): 🌟 add support for React Native 0.73 (#736)
Browse files Browse the repository at this point in the history
* 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 <md.burak.guner@gmail.com>

---------

Co-authored-by: troZee <12766071+troZee@users.noreply.github.com>
Co-authored-by: Burak Güner <md.burak.guner@gmail.com>
  • Loading branch information
3 people authored Aug 23, 2023
1 parent 5790904 commit 45d4530
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,32 @@ def getExtOrDefault(name) {
def getExtOrIntegerDefault(name) {
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['PagerView_' + name]).toInteger()
}
def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')[0].toInteger()
def shouldUseNameSpace = agpVersion >= 8
def PACKAGE_PROP = "package=\"com.reactnativepagerview\""
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 getExtOrIntegerDefault('compileSdkVersion')

if (shouldUseNameSpace){
namespace = "com.reactnativepagerview"
}
defaultConfig {
minSdkVersion getExtOrIntegerDefault('minSdkVersion')
targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
Expand Down

0 comments on commit 45d4530

Please sign in to comment.