Skip to content

Commit 9326e5a

Browse files
asamizHeshamMegid
authored andcommitted
[MOB-12515] Support React Native 0.73 (#1004)
* chore(versionSupport): add namespace in build.gradle to support upcoming 0.73 version * chore(versionSupport): fix PR comments * chore(versionSupport): fix PR comments * chore(versionSupport): modify the comment for clarification
1 parent e08ad19 commit 9326e5a

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
- Add new strings (`StringKey.discardAlertStay` and `StringKey.discardAlertDiscard`) for overriding the discard alert buttons for consistency between iOS and Android ([#1001](https://github.com/Instabug/Instabug-React-Native/pull/1001)).
88
- Add a new string (`StringKey.reproStepsListItemNumberingTitle`) for overriding the repro steps list item (screen) title for consistency between iOS and Android ([#1002](https://github.com/Instabug/Instabug-React-Native/pull/1002)).
9+
- Add support for RN version 0.73 by updating the `build.gradle` file with the `namespace` ([#1004])(https://github.com/Instabug/Instabug-React-Native/pull/1004)
910

1011
### Deprecated
1112

android/build.gradle

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,45 @@ apply from: './jacoco.gradle'
44
apply from: './native.gradle'
55
apply from: './sourcemaps.gradle'
66

7+
/* (Preparing to support RN 0.73) Checking APG version to be backward-compatible with RN versions < 0.71 */
8+
def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')[0].toInteger()
9+
def shouldUseNameSpace = agpVersion >= 7
10+
def PACKAGE_PROP = "package=\"com.instabug.reactlibrary\""
11+
def manifestOutFile = file("${projectDir}/src/main/AndroidManifest.xml")
12+
def manifestContent = manifestOutFile.getText()
13+
def isManifestContentUpdated = manifestOutFile.getText() != manifestContent
14+
def isPackageNamespaceMissing = !manifestContent.contains("$PACKAGE_PROP")
15+
716
String getExtOrDefault(String name) {
17+
def defaultPropertyKey = 'InstabugReactNative_' + name
818
if (rootProject.ext.has(name)) {
919
return rootProject.ext.get(name)
1020
}
11-
return project.properties['InstabugReactNative_' + name]
21+
return project.properties[defaultPropertyKey]
22+
}
23+
24+
if(shouldUseNameSpace){
25+
manifestContent = manifestContent.replaceAll(
26+
PACKAGE_PROP,
27+
''
28+
)
29+
} else if(isPackageNamespaceMissing) {
30+
manifestContent = manifestContent.replace(
31+
'<manifest',
32+
"<manifest $PACKAGE_PROP "
33+
)
34+
}
35+
36+
manifestContent.replaceAll(" ", " ")
37+
38+
if(isManifestContentUpdated){
39+
manifestOutFile.write(manifestContent)
1240
}
1341

1442
android {
43+
if (shouldUseNameSpace){
44+
namespace = "com.instabug.reactlibrary"
45+
}
1546
compileSdkVersion getExtOrDefault('compileSdkVersion').toInteger()
1647
buildToolsVersion getExtOrDefault('buildToolsVersion')
1748

android/src/main/AndroidManifest.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11

2-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
package="com.instabug.reactlibrary">
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
43

54
</manifest>
65

0 commit comments

Comments
 (0)